Writing Python lists to columns in csv

后端 未结 7 735

I have 5 lists, all of the same length, and I\'d like to write them to 5 columns in a CSV. So far, I can only write one to a column with this code:

with open         


        
7条回答
  •  没有蜡笔的小新
    2020-11-29 19:43

    You can use izip to combine your lists, and then iterate them

    for val in itertools.izip(l1,l2,l3,l4,l5):
        writer.writerow(val)
    

提交回复
热议问题