【发布时间】:2017-03-23 06:21:07
【问题描述】:
我正在尝试从我的字符串中删除十六进制字符 \xef\xbb\xbf 但是我收到以下错误。
不太清楚如何解决这个问题。
>>> x = u'\xef\xbb\xbfHello'
>>> x
u'\xef\xbb\xbfHello'
>>> type(x)
<type 'unicode'>
>>> print x
Hello
>>> print x.replace('\xef\xbb\xbf', '')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
>>>
【问题讨论】: