【发布时间】:2017-07-12 07:56:52
【问题描述】:
我希望下面的代码可以正常工作,但它失败了,是什么原因?
>>> s = 'ö'
>>> s.decode('utf-8')
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 0x94 in position 0: invalid start byte
【问题讨论】:
-
您的字符串未以 utf-8 编码。你用的是什么控制台?
标签: python string python-2.7 unicode encoding