endTime这个想法是获取以下标签的值xml:
<epochs xmlns="http://www.egi.com/epochs_mff" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<epoch>
<beginTime>0</beginTime>
<endTime>3586221000</endTime>
<firstBlock>1</firstBlock>
<lastBlock>897</lastBlock>
</epoch>
<epoch>
<beginTime>3750143000</beginTime>
<endTime>5549485000</endTime>
<firstBlock>898</firstBlock>
<lastBlock>1347</lastBlock>
</epoch>
</epochs>
然而,直接访问标签会返回一个空列表:
import xml.etree.ElementTree as ET
tree = ET.parse(r'epochs.xml')
epoch_list=tree.findall("epoch")
但是,遍历tree确实会返回endTime值。
import xml.etree.ElementTree as ET
tree = ET.parse(r'epochs.xml')
for elem in tree:
for subelem in elem:
print(subelem.text)
我可以知道如何直接检索endTime值为300937000的吗?
蝴蝶不菲
相关分类