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 default), thecharacters (") and (') are also translated; this helps for inclusionin an HTML attribute value delimited by quotes, as in<ahref="...">.Ifquote is set to false, the characters (") and (') are nottranslated.

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: