2016-04-21 34 views

回答

-1

您可以使用findall

tree = ET.parse(latestSumocfg) 
for grandchild in tree.findall('input/*'): 
    print(granchild.get('value')) 

,或者如果您使用了ElementTree實施lxml

tree = lxml.etree.parse(latestSumocfg) 
for value in tree.xpath('input/*/@value'): 
    print(value)