html.entities --- HTML 一般實體的定義?

源碼: Lib/html/entities.py


該模塊定義了四個詞典, html5、 name2codepointcodepoint2name、以及 entitydefs。

html.entities.html5?

將 HTML5 命名字符引用 1 映射到等效的 Unicode 字符的字典,例如 html5['gt;'] == '>'。 請注意,尾隨的分號包含在名稱中(例如 'gt;' ),但是即使沒有分號,一些名稱也會被標準接受,在這種情況下,名稱出現(xiàn)時帶有和不帶有 ';'。另見 html.unescape()。

3.3 新版功能.

html.entities.entitydefs?

將 XHTML 1.0 實體定義映射到 ISO Latin-1 中的替換文本的字典。

html.entities.name2codepoint?

將 HTML 實體名稱映射到 Unicode 代碼點的字典。

html.entities.codepoint2name?

將 Unicode 代碼點映射到 HTML 實體名稱的字典。

備注

1

See https://html.spec.whatwg.org/multipage/syntax.html#named-character-references