本文实例讲述了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程序设计有所帮助。