Python字符串处理出现错误:UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe6 in position 0: ordinal not in range(128)
import sys
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
reload(sys)
sys.setdefaultencoding(default_encoding)
本文介绍了一种常见的Python字符串处理错误——UnicodeDecodeError,并提供了解决方案。通过设置默认编码为UTF-8来避免错误的发生。
556

被折叠的 条评论
为什么被折叠?



