在Python中使用org.apache.commons.lang.StringEscapeUtils

1 投票
1 回答
1468 浏览
提问于 2025-04-15 15:42

有没有什么Python模块或者代码可以实现org.apache.commons.lang.StringEscapeUtils.escapeHtml这个功能呢?

就是和http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String)上说的一模一样。

我在网上查了查,只找到cgi.escape这个函数,但它的功能不一样。

提前谢谢你们,抱歉我的英语不好 :D

1 个回答

1

这个内容是关于XML的,不是HTML,但可能对你有帮助:转义XML

>>> from xml.sax.saxutils import escape
>>>
>>> escape("< & >")
'&lt; &amp; &gt;'

撰写回答