ElementTree 找不到元素

ElementTree cannot find element

我有一个 XML 文档,我在下面的复制器中包含了足够的子集,tree.find() returns 没有结果:

import xml.etree.ElementTree as ET

xml_str = '''
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
   <System/>
</Event>
'''

tree = ET.fromstring(xml_str)
system = tree.find('System')              

我希望 system 现在持有 <System> 标签,但它是 None。我在这里遗漏了什么吗?

当我使用数组索引(如 tree[0][0])时,它确实有效。

在搜索中使用命名空间:

>>> doc.find('{http://schemas.microsoft.com/win/2004/08/events/event}System')
<Element {http://schemas.microsoft.com/win/2004/08/events/event}System at 0x10167e5a8>