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

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)

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

posted @ 2018-04-19 11:57  bingo彬哥  阅读(5710)  评论(0编辑  收藏  举报
本站总访问量