使用Python错误消息写入新的Xml文件?

2024-10-01 13:32:14 发布

您现在位置:Python中文网/ 问答频道 /正文

这个错误消息是什么?在

我的代码

#!/usr/bin/python
from xml.dom.minidom import Document

def CreateXml(nameSpace, rootElementName):
    xmlDoc = xml.dom.minidom.Document()
    xmlRootElement = doc.createElementNS(nameSpace, rootElementName)
    xmlDoc.appendChild(xmlRootElement)

    return xmlDoc

错误是

^{pr2}$

是因为它找不到我的python的路径吗?在

提前谢谢


Tags: 代码fromimport消息binusr错误xml
1条回答
网友
1楼 · 发布于 2024-10-01 13:32:14

您忘记了import xml.dom.minidom来导入xmlmindom模块。在

>>> xml.dom.minidom.Document()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'xml' is not defined
>>> import xml.dom.minidom
>>> xml.dom.minidom.Document()
<xml.dom.minidom.Document instance at 0x7f73ae601a28>

相关问题 更多 >