html escape unescape

来源:互联网 发布:知乎周刊纸质版 编辑:程序博客网 时间:2024/06/17 11:54

参考:
https://wiki.python.org/moin/EscapingHtml

Python 3.6.0 (default, Dec 24 2016, 00:01:50)[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> import html>>> s = html.escape( """& < " ' >""" )>>> print(s)&amp; &lt; &quot; &#x27; &gt;>>> s = html.escape( '''& < " ' >''' )>>> print(s)&amp; &lt; &quot; &#x27; &gt;>>> s = html.unescape( '''&amp; &lt; &quot; &#x27; &gt;''' )>>> print(s)& < " ' >
0 0