小编kaw*_*aze的帖子

如何从 Python2.x 中的 unicode 字符串中删除转义字符(转义 unicode 字符)?

>>> 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"
Run Code Online (Sandbox Code Playgroud)

那么我将如何从 test2 转换为 test(即打印 unicode 字符)?.decode('utf-8')不这样做。

python unicode python-2.7

3
推荐指数
1
解决办法
2029
查看次数

标签 统计

python ×1

python-2.7 ×1

unicode ×1