Writing Python lists to columns in csv

后端 未结 7 711

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:53

    I just wanted to add to this one- because quite frankly, I banged my head against it for a while - and while very new to python - perhaps it will help someone else out.

     writer.writerow(("ColName1", "ColName2", "ColName"))
                     for i in range(len(first_col_list)):
                         writer.writerow((first_col_list[i], second_col_list[i], third_col_list[i]))
    
    0 讨论(0)
提交回复
热议问题