>>> 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