相关疑难解决方法(0)

UnicodeDecodeError,无效的连续字节

为什么以下项目失败?为什么它会成功使用"latin-1"编解码器?

o = "a test of \xe9 char" #I want this to remain a string as this is what I am receiving
v = o.decode("utf-8")
Run Code Online (Sandbox Code Playgroud)

结果是:

 Traceback (most recent call last):  
 File "<stdin>", line 1, in <module>  
 File "C:\Python27\lib\encodings\utf_8.py",
 line 16, in decode
     return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError:
 'utf8' codec can't decode byte 0xe9 in position 10: invalid continuation byte
Run Code Online (Sandbox Code Playgroud)

python unicode decode

217
推荐指数
10
解决办法
51万
查看次数

标签 统计

decode ×1

python ×1

unicode ×1