首页 > 解决方案 > 如何防止python中的字符引用?

问题描述

如何阻止'"'变成'"' 下面的代码?

>>> from xml.dom.minidom import Document
>>> doc=Document()
>>> name_element = doc.createElement('name')
>>> name_text = doc.createTextNode('"tom"')
>>> name_element.appendChild(name_text)
<DOM Text node "'"tom"'">
>>> name_element.toxml()
'<name>&quot;tom&quot;</name>'

标签: python

解决方案


推荐阅读