本文实例讲述了Python导出数据到Excel可读取的CSV文件的方法。分享给大家供大家参考。具体实现方法如下:
import csv
with open('eggs.csv', 'wb') as csvfile:
#spamwriter = csv.writer(csvfile, delimiter=' ',quotechar='|',
#quoting=csv.QUOTE_MINIMAL)
spamwriter = csv.writer(csvfile, dialect='excel')
spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
希望本文所述对大家的Python程序设计有所帮助。
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8