Reputation: 110153
>>> 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)
How would I get the 未作評級
into uniciode?
Upvotes: 3
Views: 1971
Reputation: 336138
Either use a Unicode string from the start:
>>> s = u'未作評級'
or decode the string from its current encoding (which appears to be UTF-8). Then you get a Unicode string.
>>> s = '未作評級'.decode("utf-8")
Upvotes: 6