在python 2.7.3中使用itertext()时出错

时间:2015-11-26 01:59:27

标签: python-2.7

当我运行下面的代码时,收到一条消息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(),所以我做错了什么?

0 个答案:

没有答案