Escape html in python?

前端 未结 5 720
终归单人心
终归单人心 2021-01-02 23:06

i have a but string might contain \", what should I do to escape it?

Example:

__string__ = t         


        
5条回答
  •  难免孤独
    2021-01-02 23:13

    If your value being escaped might contain quotes, the best thing is to use the quoteattr method: http://docs.python.org/library/xml.sax.utils.html#module-xml.sax.saxutils

    This is referenced right beneath the docs on the cgi.escape() method.

提交回复
热议问题