Python 3 では、 and を使用"string".encode()
し"string".decode()
て、Unicode 文字列をバイト文字列に変換するか、バイト文字列を Unicode 文字列に変換します。
Python 2 では、 と がありstr()
、unicode()
これらも可能です。しかし、Python 3 との違いはありますか?encode()
decode()
python2 では、str はバイト文字列、unicode は unicode 文字列です。しかし、エンコードとデコードのばかげたこと、詳細はhttp://nedbatchelder.com/text/unipain.htmlを参照してください