本文实例讲述了Python导出数据到Excel可读取的CSV文件的方法。分享给大家供大家参考。具体实现方法如下:
1
2
3
4
5
6
7
|
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程序设计有所帮助。