假设我有以下内容-
<test> This is some text </test>
<test> This is other text </test>现在,我想从这两个标记中提取内容,但是能够将它们称为tag-1和tag-2,这样我就可以单独使用它们。我该怎么做?
发布于 2016-03-21 21:07:52
使用root.findall(“测试”)。这将返回元素列表--使用索引,而不是不同的标记名。
root.findall("test")[0].text --> "This is some text"
root.findall("test")[1].text --> "This is other text"https://stackoverflow.com/questions/36141103
复制相似问题