12 2016 档案

摘要:在用python编码时,经常会碰到编码问题,UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128),其实编码问题可以通过decode与encode来解决。 阅读全文
posted @ 2016-12-29 17:23 蜗牛到牛 阅读(184) 评论(0) 推荐(0)
摘要:1、操作csv文件 1)、读取文件 import csv f=open("test.csv",'r') t_text=csv.reader(f) for t,i in t_text: print t,i csv.reader把每一行数据转化成了一个list,list中每个元素是一个字符串。 2)、写 阅读全文
posted @ 2016-12-20 16:23 蜗牛到牛 阅读(844) 评论(0) 推荐(0)
摘要:python多线程有两种用法,一种是在函数中使用,一种是放在类中使用 1、在函数中使用 定义空的线程列表 threads=[] 创建线程 t=threading.Thread(target=函数名,args=(函数参数,必须为元组类型))#若函数中没有参数,则args参数可省略不写 将线程加到线程列 阅读全文
posted @ 2016-12-16 17:05 蜗牛到牛 阅读(221) 评论(0) 推荐(0)