Python html Module
Example
Escape and unescape HTML text:
import html
text = "<b>Title</b>"
print(html.escape(text))
print(html.unescape("<b>Title</b>"))
Try it Yourself »
Definition and Usage
The html module provides utilities for working with HTML text, such as escaping and unescaping special characters.
Use it to safely display text in HTML contexts and to convert entities back to their literal characters.
Members
Member | Description |
---|---|
escape() | Replace special characters & < > ' " with HTML-safe sequences. |
unescape() | Convert all named and numeric character references to the corresponding unicode characters. |