html --- 超文本标记语言支持

源码: Lib/html/__init__.py


该模块定义了操作HTML的工具。

html.escape(s, quote=True)

Convert the characters &, < and > in string s to HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. If the optional flag quote is true (the default), the characters (") and (') are also translated; this helps for inclusion in an HTML attribute value delimited by quotes, as in <a href="...">. If quote is set to false, the characters (") and (') are not translated.

Added in version 3.2.

html.unescape(s)

将字符串 s 中的所有命名和数字字符引用 (例如 &gt;, &#62;, &#x3e;) 转换为相应的Unicode字符。 此函数使用HTML 5标准为有效和无效字符引用定义的规则,以及 HTML 5 命名字符引用列表

Added in version 3.4.


html 包中的子模块是: