UnicodeEncodeError: 'ascii' codec can't encode character u'u65e0' in position 1(

Posted 开源、架构、Linux C/C++/python AI BI

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UnicodeEncodeError: 'ascii' codec can't encode character u'u65e0' in position 1(相关的知识,希望对你有一定的参考价值。

 

UnicodeEncodeError: \'ascii\' codec can\'t encode character u\'\\u65e0\' in position 1: ordinal not in range(128)

上述问题解决办法

修改tool.py

s = json.dumps(obj, sort_keys=True, indent=4, ensure_ascii=False)
        outfile.write(codecs.encode(s, \'utf-8\'))

修改后

修改前

 

以上是关于UnicodeEncodeError: 'ascii' codec can't encode character u'u65e0' in position 1(的主要内容,如果未能解决你的问题,请参考以下文章

UnicodeEncodeError: 'ascii' codec can't encode character u'u5929' in position 2(

UnicodeEncodeError: 'ascii' codec can't encode characters

UnicodeEncodeError: 'ascii' codec can't encode characters in

UnicodeEncodeError: 'gbk' codec can't encode character 'xbb' in position

UnicodeEncodeError: 'ascii' codec can't encode character...的解决方法

UnicodeEncodeError: 'gbk' codec can't encode character 'u25aa' in position 15: (