8
タイトルとして、str()をunicode文字列をstrにキャストする理由はありませんか?Python str(u'a ')とu'a'.encode(' utf-8 ')の違いは何ですか?
>>> str(u'a')
'a'
>>> str(u'a').__class__
<type 'str'>
>>> u'a'.encode('utf-8')
'a'
>>> u'a'.encode('utf-8').__class__
<type 'str'>
>>> u'a'.encode().__class__
<type 'str'>
UPDATE:答えてくれてありがとう、また、私は特殊文字を使用して文字列を作成する場合には、自動的にUTF-8
>>> a = '€'
>>> a.__class__
<type 'str'>
>>> a
'\xe2\x82\xac'
に変換されます知りませんでしたが、またのpython 3でUnicodeオブジェクトであります