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