这里博主只贴出自己写的代码
import csv
a=[[x for x in range(64)]]*10
b=[13,14]
with open('csvfilea.csv','w') as csvresult:
spamwriter=csv.writer(csvresult,dialect='excel')
for a1 in a:
spamwriter.writerow((a1))
with open('csvfileb.txt', 'w') as csvresult:
for i in b:
csvresult.write(str(i)+'\r\n')详情可以参考:
http://www.41443.com/HTML/Python/20130311/137281.html
本文分享了一个使用Python进行CSV文件写入的例子。通过两段代码演示了如何将列表数据写入CSV文件中,一段使用csv模块的writer方法,另一段直接打开文件并写入。适合初学者参考学习。
4万+

被折叠的 条评论
为什么被折叠?



