On this page
  1. html.escape
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

html.escape

Up: html | Next: html.unescape
Rel: html.unescape
Ref: docs.python.org — html.escape
Tags: #public #python3 #stdlib #html


Import

import html
from html import escape

Signature & Overview

html.escape(s, quote=True)

Replace special characters "&", "<" and ">" to HTML-safe sequences.

Usage

import html

assert html.escape('<a href="x">A & B</a>') == '&lt;a href=&quot;x&quot;&gt;A &amp; B&lt;/a&gt;'

Gotchas

REPL Inspect

from html import escape
help(escape)

Linked from

Related notes