findall()只需要2个参数(给出3个)

时间:2014-02-03 23:23:26

标签: python elementtree

这是我的代码:

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)

堆栈跟踪:

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)

我正在按照文档中给出的示例进行操作。

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

我做错了什么?

0 个答案:

没有答案