3
>>> test
u'"Hello," he\u200b said\u200f\u200e.\n\t"I\u200b am\u200b nine years old\xe2"'
>>> test2
'"Hello," he\\u200b said\\u200f\\u200e.\n\t"I\\u200b am\\u200b nine years old"'
>>> print test
"Hello," he said.
"I am nine years oldâ"
>>> print test2
"Hello," he\u200b said\u200f\u200e.
"I\u200b am\u200b nine years old"
那么我如何从test2转换到测试(即打印unicode字符)呢? .decode('utf-8')
不这样做。如何从Python2.x中的unicode字符串中删除转义字符(转义Unicode字符)?
是否打印了转义的unicode字符?鉴于在这个例子中的零空间,我无法确定。我假设u'\ xe2'不能被打印,因为它不是unicode? – kawakaze
@kawakaze,'u'\ xe2''是'LATIN小字母A CIRCUMFLEX'。你可以使用'unicodedata.name(u'\ xe2')来检查' – falsetru
非常感谢! – kawakaze