标签:color head over 设置 hang nbsp python lis file
import csv
rowlist=[{‘first_name‘: ‘mark‘, ‘last_name‘: ‘zhao‘,‘age‘:21},
{‘first_name‘: ‘tony‘, ‘last_name‘: ‘wang‘,‘age‘:22},
{‘first_name‘: ‘hengry‘, ‘last_name‘: ‘zhang‘,‘age‘:23},]
#newline设置为空
with open(‘names.csv‘, ‘w‘,newline=‘‘) as csvfile:
#构造三个列
col_names = [‘first_name‘, ‘last_name‘,‘age‘]
writer = csv.DictWriter(csvfile, col_names)
#从头部开始按行写入数据
writer.writeheader()
writer.writerows(rowlist)
print(".......................writer over............")
标签:color head over 设置 hang nbsp python lis file
原文地址:http://www.cnblogs.com/youngyang/p/7808444.html