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.

 

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'))

修改后

修改前

 

目录
相关文章
|
2月前
|
Python
8-7|TypeError: The fill character must be a unicode character, not bytes
8-7|TypeError: The fill character must be a unicode character, not bytes
|
4月前
|
编解码 开发者 Python
详解'unicodeescape' codec can't decode bytes in position 16-17: malformed \N character escape
遇到“`unicodeescape` codec can't decode bytes in position X-X: malformed \N character escape”错误时,首先不要慌张。通过逐步检查和修正代码中的Unicode转义序列,大多数情况下都能找到问题的根源并加以解决。有效利用Python的Unicode支持特性,可以优雅地处理各种复杂的字符编码问题。
120 3
|
4月前
|
编解码 测试技术 Python
【Python】已解决:UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not i
【Python】已解决:UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-1: ordinal not i
716 1
|
4月前
|
编解码
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe9 in position 3114: invalid continuation byte
UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xe9 in position 3114: invalid continuation byte
成功解决UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 130: invalid continuation b
成功解决UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 130: invalid continuation b
成功解决UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 130: invalid continuation b
|
编解码 Python
问题解决:UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xcf in position 0: invalid continuation by
问题解决:UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xcf in position 0: invalid continuation by
3631 0
问题解决:UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xcf in position 0: invalid continuation by
|
编解码 固态存储 Python
ssd [Error] UnicodeDecodeError: 'gbk' codec can't decode byte 0x81 in position【已解决】
ssd [Error] UnicodeDecodeError: 'gbk' codec can't decode byte 0x81 in position【已解决】
378 0
ssd [Error] UnicodeDecodeError: 'gbk' codec can't decode byte 0x81 in position【已解决】
|
编解码
UnicodeEncodeError: 'latin-1' codec can't encode characters in position报错问题
UnicodeEncodeError: 'latin-1' codec can't encode characters in position报错问题
1194 1
|
机器学习/深度学习 编解码 Python
成功解决Python3版UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in
成功解决Python3版UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in
成功解决Python3版UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0x90 in position 614: ordinal not in
成功解决SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa3 in position 15: invalid start
成功解决SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa3 in position 15: invalid start