html.escape()和.unescape()不是对称的。根据 the docs ,escape只转换&、<和>,而.unescape处理“所有命名和数字字符引用”。如何转义.unescape()unescapes的所有字符?
当前行为:
html.unescape('°') '°' html.escape('°') '°'
html.unescape('°') '°' html.escape('°') '°'
您链接到的文档链接到此:
html.entities.codepoint2name
正如另一张海报所指出的,你可能并不真的想逃跑 一切 ,因为每个字符都有实体名,或者至少有数字转义。