2024-10-01 09:28:02 发布
网友
我试着编码,但没有成功。你知道吗
text = "don\\u2019t think" textencode = text.encode('utf-8').split(" ") print textencode
结果仍然是['don\u2019t','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”。你知道吗
看起来你在用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中
在双引号前加前缀“u”。你知道吗
看起来你在用Python2。这就是你要找的吗?你知道吗
Python3可以更好地处理unicode对象
相关问题 更多 >
编程相关推荐