当我运行下面的代码时,收到一条消息AttributeError: 'ElementTree' object has no attribute 'itertext'
import xml.etree.cElementTree as ET
url = '[filenamehere].xml'
tree = ET.ElementTree(file=url)
for elem in tree.itertext():
print repr(elem)
它适用于tree.iter()
我在Linux Mint Maya中使用Python 2.7.3。根据Python文档,在{2.7}中添加了itertext()
,所以我做错了什么?