更新时间:2023-02-23 12:09:55
您无法解码 unicode
,也无法编码 str
.试试反过来.
Here are my attempts with error messages. What am I doing wrong?
string.decode("ascii", "ignore")
UnicodeEncodeError: 'ascii' codec can't encode character u'\xa0' in position 37: ordinal not in range(128)
string.encode('utf-8', "ignore")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 37: ordinal not in range(128)
You can't decode a unicode
, and you can't encode a str
. Try doing it the other way around.