html
— HyperText Markup Language support超文本标记语言支持¶
Source code: Lib/html/__init__.py
This module defines utilities to manipulate HTML.此模块定义用于操作HTML的实用程序。
-
html.
escape
(s, quote=True)¶ Convert the characters将字符串&
,<
and>
in string s to HTML-safe sequences.s
中的字符&
、<
和>
转换为HTML安全序列。Use this if you need to display text that might contain such characters in HTML.如果需要在HTML中显示可能包含此类字符的文本,请使用此选项。If the optional flag quote is true, the characters (如果可选标志quote为"
) and ('
) are also translated; this helps for inclusion in an HTML attribute value delimited by quotes, as in<a href="...">
.true
,则字符("
)和('
)也会被翻译;这有助于包含在由引号分隔的HTML属性值中,如在<a href="...">
中。New in version 3.2.版本3.2中新增。
-
html.
unescape
(s)¶ Convert all named and numeric character references (e.g.转换所有命名和数字字符引用(例如>
,>
,>
) in the string s to the corresponding Unicode characters.>
、>
、>
)将字符串中的s转换为相应的Unicode字符。This function uses the rules defined by the HTML 5 standard for both valid and invalid character references, and the此函数使用HTML 5标准为有效和无效字符引用定义的规则,以及HTML 5命名字符引用列表。list of HTML 5 named character references
.New in version 3.4.版本3.4中新增。
Submodules in the html
package are:html
包中的子模块包括:
html.parser
–HTML/XHTML parser with lenient parsing mode具有宽松解析模式的HTML/XHTML解析器html.entities
–HTML entity definitionsHTML实体定义