如果我在 XML 文件上运行以下 python(参见 Q 底部):
import xml.etree.ElementTree as ET
tree = ET.parse('C:\\temp\\test2.xml')
print(tree.getchildren())
我收到错误:
AttributeError:“ElementTree”对象没有属性“getchildren”
我将 XML 上传到在线验证器,它说 XML 没问题。
树本身没有getchildren()
method.
print(tree.getroot().getchildren())
注意getchildren()
已弃用。看文档 https://docs.python.org/2/library/xml.etree.elementtree.html#element-objects
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)