Python XML escape Python 专用于XML字符串转移的函数。
escape example
from xml.sax.saxutils import escape
escape("< & >")
output:'< & >'
quoteattr example
>>> from xml.sax.saxutils import quoteattr
>>>
>>> quoteattr("some value ' containing an apostrophe")
'"some value \' containing an apostrophe"'
>>> quoteattr('some value containing " a double-quote')
'\'some value containing " a double-quote\''
>>> quoteattr('value containing " a double-quote \' and an apostrophe')
'"value containing " a double-quote \' and an apostrophe"'