cgi.escape()

cgi.escape(s, quote=None)[source]

Replace special characters “&”, “<” and “>” to HTML-safe sequences. If the optional flag quote is true, the quotation mark character (”) is also translated.