gpt4 book ai didi

python - 统一码编码错误 : 'gbk' codec can't encode character '\ue13b' in position 25: illegal multibyte sequence

转载 作者:太空宇宙 更新时间:2023-11-04 04:14:08 26 4
gpt4 key购买 nike

错误:

 UnicodeEncodeError: 'gbk' codec can't encode character '\ue13b' in position 25: illegal multibyte sequence

文件编码格式为utf-8,读取文件时出现无法识别的字。 ‘左足趾 NumPy ’

代码:

for line in open(label_filepath, encoding='utf-8'):
print(line)

最佳答案

将原生编码改为utf-8

import sys
import io
sys.stdout = io.TextIOWrapper(buffer=sys.stdout.buffer,encoding='utf8')

关于python - 统一码编码错误 : 'gbk' codec can't encode character '\ue13b' in position 25: illegal multibyte sequence,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55774642/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com