i have a <img src=__string__>
but string might contain ", what should I do to escape it?
Example:
__string__ = test".jpg
<img src="test".jpg">
doesn't work.
In Python 3.2 a new html
module was introduced, which is used for escaping reserved characters from HTML markup.
It has one function html.escape(s, quote=True)
.
If the optional flag quote is true, the characters (")
and (')
are also translated.
Usage:
>>> import html
>>> html.escape('x > 2 && x < 7')
'x > 2 && x < 7'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With