エンコードしようとしましたが、成功しませんでした。
text = "don\\u2019t think"
textencode = text.encode('utf-8').split(" ")
print textencode
結果はまだ ['don\u2019t', 'think']
私は[「しない」、「考える」]を得ようとしました
なにか提案を?
エンコードしようとしましたが、成功しませんでした。
text = "don\\u2019t think"
textencode = text.encode('utf-8').split(" ")
print textencode
結果はまだ ['don\u2019t', 'think']
私は[「しない」、「考える」]を得ようとしました
なにか提案を?
Python2を使用しているようです。これはあなたが探しているものですか?
>>> text = u"don\u2019t think"
>>> textencode = text.encode('utf-8').split(" ")
>>> print textencode[0]
don’t
Python3 は Unicode オブジェクトをよりうまく処理します
>>> text = "don\u2019t think"
>>> textencode = text.split(" ")
>>> textencode
['don’t', 'think']
Python2.xでは
>>> text = u"don\u2019t think"
>>> textencode = text.encode('utf-8').split(" ")
>>> print textencode
['don\xe2\x80\x99t', 'think']
>>> print textencode[0]
don’t
二重引用符の前に接頭辞「u」を付けます。