我打算将以下列表附加到csv文件中,以便它出现在单行中,但我的代码不起作用。我是python的初学者。欢迎提出任何建议。谢谢你。
list_one = ['apple','ball','cat','dog']
我尝试了以下代码:
import csv
list = ['apple','cat','dog']
with open('document.csv','a') as fd:
fd.writerows(list)
import csv
list = ['apple','cat','dog']
with open('document.csv','a') as fd:
write = csv.writer(fd)
write.writerow(list)