when writing to csv file writerow fails with UnicodeEncodeError

前端 未结 2 449
南方客
南方客 2021-01-17 12:48

I have the line:

c.writerow(new_values)

That writes a number of values to a csv file. Normally it is working fine but sometimes it throws a

2条回答
  •  生来不讨喜
    2021-01-17 13:00

    the csv module in python is notorious for not handling unicode characters well. Unless all characters fall in the ascii codec you probably won't be able to write the row. There is a (somewhat) drop in replacement called unicodecsv that you may want to look into. https://pypi.python.org/pypi/unicodecsv

提交回复
热议问题