Why does bool(xml.etree.ElementTree.Element) evaluate to False?

前端 未结 2 753
遥遥无期
遥遥无期 2020-12-15 03:35
import xml.etree.ElementTree as ET
e = ET.Element(\'Brock\',Role=\"Bodyguard\")
print bool(e)

Why is an xml.etree.ElementTree.Element

2条回答
  •  我在风中等你
    2020-12-15 04:12

    From the docs:

    http://docs.python.org/library/xml.etree.elementtree.html#element-objects

    Caution: Elements with no subelements will test as False. This behavior will change in future versions. Use specific len(elem) or elem is None test instead.

提交回复
热议问题