>>> s='未作評級' >>> s '\xe6\x9c\xaa\xe4\xbd\x9c\xe8\xa9\x95\xe7\xb4\x9a' >>> s = unicode(s) UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128) 我该如何将未作評級转换为Unicode编码?
可以从一开始使用Unicode字符串: >>> s = u'未作評級' 或者对当前编码的字符串进行解码(似乎是UTF-8编码)。然后你会得到一个Unicode字符串。 >>> s = '未作評級'.decode("utf-8")