Name
escape
Synopsis
escape(data
,entities
={})
Returns a copy of string data
with
characters <
, >
, and
&
changed into entity references
<
, >
, and
&
. entities
is
a dictionary with strings as keys and values; each substring
s
of data
that
is a key in entities
is changed in
escape
’s result string into
string
entities
[
s
]
.
For example, to escape single and double quote characters, in
addition to angle brackets and ampersands, you can call:
xml.sax.saxutils.escape(data
,{'"':'"', "'":"'"})
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.