How to write List of lists in csv file in python

后端 未结 2 568
猫巷女王i
猫巷女王i 2020-12-03 15:09

I have a list of lists and I want to write it in csv file Example list:

data=[[\'serial\', \'name\', \'subject\'],[\'1\', \'atul\',\'tpa\'],[\'2\', \'carl\',         


        
2条回答
  •  星月不相逢
    2020-12-03 15:39

    I get the following error when I include newline='': TypeError: 'newline' is an invalid keyword argument for this function.

    This is what I used and worked fine for me.

    csv_file = open("your_csv_file.csv", "wb")
    writer = csv.writer(csv_file)
    writer.writerows(clean_list)
    

提交回复
热议问题