python对csv文件导出与读取

python导出csv文件
# coding: utf-8 import csv csvfile = open('csv.csv', 'wb') #打开方式还可以使用file对象 writer = csv.writer(csvfile) writer.writerow(['姓名', '年龄', '电话']) data = [ ('小河', '25', '1234567'), ('小芳', '18', '789456') ] writer.writerows(data) csvfile.close()

 

python读取csv文件
# coding: utf-8 import csv csvfile = open('test.csv', 'rb') reader = csv.reader(csvfile) for line in reader: print line csvfile.close()
posted @ 2018-07-13 11:00  Awakenedy  阅读(4281)  评论(0)    收藏  举报