标签:文件读写 row csv pen targe tar imp pytho ref
import csv;
csv_reader=open("e:/python/csv_data/log.csv" , ‘r‘) data=[] for line in csv_reader: data.append(list(line.strip().split(‘|‘))) for line in data: print(line)
import sys; reload(sys) sys.setdefaultencoding("utf-8"); csv_reader=csv.reader(file(‘E:\\Python\CSV_data\log.csv‘,‘rb‘)) for row in csv_reader: print(row) writer=csv.writer(file(‘E:\\Python\CSV_data\log_write.csv‘,‘wb‘)) writer.writerow([‘name‘,‘id‘,‘comment‘]) lines=[range(3) for i in range(5)] for line in lines: writer.writerow(line)
reader1=csv.DictReader(file(‘E:\\Python\CSV_data\women_write.csv‘,‘rb‘))
标签:文件读写 row csv pen targe tar imp pytho ref
原文地址:http://www.cnblogs.com/skyEva/p/6803301.html