escape和unescape
s = 'Elements are written as "<tag>text</tag>".'
import html
print(html.escape(s))
# Elements are written as "<tag>text</tag>".
# Disable escaping of quotes
print(html.escape(s, quote=False))
# Elements are written as "<tag>text</tag>".
t = 'The prompt is >>>'
print(html.unescape(t)) # The prompt is >>>
文档信息
- 本文作者:zhupite
- 本文链接:https://zhupite.com/python/python-escape.html
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)