python xml处理中文时出现的错误,记录一下,以免忘记
"UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)"
解决办法,在该python文件的前面加上如下几句,问题得到解决。
import sys
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
reload(sys)
sys.setdefaultencoding(default_encoding)
本文介绍了在使用Python处理XML文件中遇到的中文字符编码问题,并提供了一种解决方案,即通过设置系统的默认编码为UTF-8来避免UnicodeDecodeError错误。
936

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



