如果elem vs. elem不是没有

时间:2014-07-30 07:39:30

标签: python python-2.7

使用Elementtree解析XML文档我有以下条件

pl = xml_task.find(namespace_tag('PredecessorLink'))

if pl :
    ....

但是Python给了我一个警告/通知,它应该是

if pl is not None :
    ...

我知道第一个和第二个条件之间存在差异,但我不理解以下警告:

FutureWarning: The behavior of this method will change in future versions. 
Use specific 'len (elem)' or 'elem is not None' test instead.

0 个答案:

没有答案
相关问题