此代碼:LXML元布爾檢查
from lxml.html import fromstring, tostring
s = '<span class="left">Whatever</span>'
e = fromstring(s)
print(tostring(e))
print(bool(e))
輸出:
<span class="left">Whatever</span>
False
爲什麼?如何布爾檢查在這個類中工作?請指出我的相關文件或代碼。
PS
進出口使用lxml
3.3.5
如果你想測試一些不是空的:'not not「」'is False while'not not「something」'是True – daouzli