html — HyperText Markup Language support

Source code:Lib/html/__init__.py


This module defines utilities to manipulate HTML.

html.escape(s,quote=True)

Convert the characters&,< and> in strings to HTML-safesequences. Use this if you need to display text that might contain suchcharacters in HTML. If the optional flagquote is true, the characters(") and (') are also translated; this helps for inclusion in an HTMLattribute value delimited by quotes, as in<ahref="...">.

Added in version 3.2.

html.unescape(s)

Convert all named and numeric character references (e.g.&gt;,&#62;,&#x3e;) in the strings to the corresponding Unicodecharacters. This function uses the rules defined by the HTML 5 standardfor both valid and invalid character references, and thelistofHTML5namedcharacterreferences.

Added in version 3.4.


Submodules in thehtml package are: