[错误解决]UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

时间:2023-12-31 08:40:02

python2内容无法写入csv,报错:UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

因为要跟2的代码对接,代码需要写入表格,但是一直写入不进去,一直报错:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

查看*发现安装unicodecsv可以解决
安装:pip2 install unicodecsv
使用:
把 import csv
改成 import unicodecsv as csv in your code