Python3 csv writer failing, exiting on error "TypeError: 'newline' is an invalid keyword argument for this function

前端 未结 4 410
盖世英雄少女心
盖世英雄少女心 2021-01-20 19:33

What I\'m trying to do:

I\'m trying to change the formatting on a csv file from space delimited to comma delimited.

What I\'ve don

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-20 20:04

    newline does not work in with open('output.csv', 'a',newline='') as fp. It will return back an error:

    'newline' is an invalid keyword argument for this function

    I used 'ab' method and it worked without blank lines between the lines:

    with open('output.csv', 'ab',) as fp
    

提交回复
热议问题