【发布时间】:2019-03-19 18:28:25
【问题描述】:
我有以下 XML 文件:
<annotations count="1">
<track id="0" label="Machine">
<box frame="0" ><attribute id="8">act1</attribute></box>
<box frame="1" ><attribute id="8">act2</attribute></box>
<box frame="2" ><attribute id="8">act1</attribute></box>
</track>
</annotations>
我想提取 frame 和 action inside 属性。例如我想要 (frame: 0 , act1), (frame: 1 , act2) ... 现在我正在做的是
root = xml.etree.ElementTree.parse(xml_file_path).getroot()
for track in root.iter('track'):
for box in track.iter('box'):
frame = box.get('frame')
我怎样才能获得相应的属性(act1,...,act 1)?
【问题讨论】: