Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当 xml.dom.minidom 解析一段 xml 时,它会自动将大于和小于的转义字符转换为它们的可视化表示。例如:
>>> import xml.dom.minidom >>> s = "<example>4 < 5</example>" >>> x = xml.dom.minidom.parseString(s) >>> x.firstChild.firstChild.data u'4 < 5'
有谁知道如何阻止 minidom 这样做?
>>> import xml.dom.minidom >>> s = "<example>4 < 5</example>" >>> x = xml.dom.minidom.parseString(s) >>> x.firstChild.firstChild.toxml() u'4 < 5'