findall() takes exactly 2 arguments (3 given)

柔情痞子 提交于 2019-12-11 18:15:41

问题


here's my code:

from elementTree.elementtree.ElementTree import Element, parse, ElementTree

f = open("myxml.xml", 'r')
tree = parse(f)
root = tree.getroot()
f2 = open('out.xml', 'w')

print tree
print root

props = root.findall('property')
print props             

tree.write(f2)

Stacktrace:

Traceback (most recent call last):
  File "xmlpy.py", line 11, in <module>
    props = root.findall('property')
  File "D:\user-testing-areas\DWJ\py\elementTree\elementtree\ElementTree.py", li
ne 390, in findall
    return ElementPath.findall(self, path, namespaces)
TypeError: findall() takes exactly 2 arguments (3 given)

I'm following the examples given in the documentation.

http://docs.python.org/2/library/xml.etree.elementtree.html

What am I doing wrong?

来源:https://stackoverflow.com/questions/21539924/findall-takes-exactly-2-arguments-3-given

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!