import csv
birth_header = [1,2,4,5,6,7]
#这个作为标题传入文件
birth_data = [['123','12','黑救护车你是'],['sav','savc','afcv']]
#这是数据
with open('./a.csv','a+',newline='') as f:
#打开文件并以a(追加)的方式写入
# with open(birth_weight_file, "w") as f:
writer = csv.writer(f)
writer.writerows([birth_header])
writer.writerows(birth_data)
f.close()
python中csv文件写入
最新推荐文章于 2022-06-10 20:57:09 发布