我有这样的代码,试图写(名单)名单为CSV,其中每个项目(这是一个清单)应写为新的CSV行:蟒蛇列表写为csv
resultFile = open("E:/tmobile/CR_Accuracy/cycle7/pp/output.csv",'wb')
wr = csv.writer(resultFile, dialect='excel')
for item in result:
wr.writerow([item,])
由于一些奇怪的原因,在代码执行并完成后,csv文件是空的。 从“观察”与PyCharm到几个列表项副本的例子:
(7031482579417L, 'Payment', 'Yes', 'Yes - Both')
(7031482579417L, 'Rate Plan OR Plan Fit Analysis', 'Yes', 'Yes - System')
(7031482579417L, 'Credits and Adjustments', 'Yes', 'Yes - Both')
你做了'resultFile.close()'? – theharshest 2014-11-05 07:12:24