csv.write skipping lines when writing to csv

后端 未结 5 1516
旧巷少年郎
旧巷少年郎 2021-01-01 11:50

I am trying to write to a csv file via the following

file = open(\'P:\\test.csv\', \'a\') 

fieldnames = (\'ItemID\', \'Factor\', \'FixedAmount\')
wr = csv.D         


        
5条回答
  •  庸人自扰
    2021-01-01 11:54

    You need to pass an additional parameter to the 'open()' function:

    file = open('P:\test.csv', 'a', newline='')
    

    This will keep it from skipping lines.

提交回复
热议问题