【发布时间】:2015-04-30 12:47:42
【问题描述】:
具体来说,\xe2\x80\x93 中的每个转义符是做什么的,为什么需要 3 个转义符?尝试自行解码会导致“数据意外结束”错误。
>>> print(b'\xe2\x80\x93'.decode('utf-8'))
–
>>> print(b'\xe2'.decode('utf-8'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe2 in position 0: unexpected end of data
【问题讨论】:
标签: python unicode encoding utf-8