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()

浙公网安备 33010602011771号