我将数据从循环写入csv文件.
预期结果:每次迭代都应在新列中写入数据.
实际上,它会覆盖上一次迭代的数据.如何为每次迭代添加新列?
def keywordsToCsv(filename,single_phrases):
path = 'keywords/keywords.csv'
with open(path,'w',encoding='utf-8') as csvfile:
filewriter = csv.writer(csvfile,delimiter=',',quotechar='|',quoting=csv.QUOTE_MINIMAL)
filewriter.writerow([filename])
for phrase in single_phrases:
filewriter.writerow([phrase])
最佳答案
原文链接:https://www.f2er.com/python/533206.html