每天CookBook之Python-037
- html字符串互转
import html
s = 'Elements are written as "<tag>text</tag>".'
print(s)
print(html.escape(s))
print(html.escape(s, quote=False))
s = 'Spicy "Jalapeño".'
p = html.unescape(s)
print(p)
Elements are written as "<tag>text</tag>".
Elements are written as "<tag>text</tag>".
Elements are written as "<tag>text</tag>".
Spicy "Jalapeño".