首页 > 代码库 > UnicodeEncodeError: 'ascii' codec can't encode character u'\u65e0' in position 1: ordinal not in range(128)

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

 

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: ordinal not in range(128)