html --- 超文本標記語言 (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.

在 3.2 版被加入.

html.unescape(s)

將字串 s 中所有附名 (named) 且為數值的 (numeric) 字元參照(如: &gt;&#62;&#x3e; )轉換為對應的 Unicode 字元。此函式針對有效及無效的字元參照,皆使用 HTML 5 標準所定義的規則,以及 HTML 5 附名字元參照清單

在 3.4 版被加入.


html 套件中的子模組為: