本文實例講述了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程序設計有所幫助。