>>> text = 'text'
>>> btext = b'text'
>>> utext = u'text'
>>> text
'\xe3\x83\x86\xe3\x82\xad\xe3\x82\xb9\xe3\x83\x88'
>>> print text
text
>>> btext
'\xe3\x83\x86\xe3\x82\xad\xe3\x82\xb9\xe3\x83\x88'
>>> btext.decode('utf-8')
u'\u30c6\u30ad\u30b9\u30c8'
>>> print btext.decode('utf-8')
text
>>> print btext
text
>>> utext
u'\u30c6\u30ad\u30b9\u30c8'
>>> print utext
text
>>> text = 'text'
>>> btext = b'text'
File "<stdin>", line 1
SyntaxError: bytes can only contain ASCII literal characters.
>>> utext = u'text'
>>> text
'text'
>>> print(text)
text
>>> utext
'text'
>>> print(utext)
text
Recommended Posts