将ascii字符转换为普通文本

2024-05-14 00:20:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我有这样的文字:

‘The zoom animations everywhere on the new iOS 7 are literally making me nauseous and giving me a headache,’wroteforumuser Ensorceled.

我知道#8216是一个ASCII码性格。怎么我可以不使用.replace将其转换为普通字符吗。在


Tags: andthenewonareiosme文字
1条回答
网友
1楼 · 发布于 2024-05-14 00:20:21

这里有一个HTML转义。使用^{} class可取消对以下内容的浏览:

from HTMLParser import HTMLParser

parser = HTMLParser()
unescaped = parser.unescape(escaped)

演示:

^{pr2}$

在Python3中,HTMLParser模块已重命名为^{};相应地调整导入:

from html.parser import HTMLParser

相关问题 更多 >