5 回答
TA贡献1884条经验 获得超4个赞
因为你写的xpath没有匹配到数据,所以给你返回的是一个空的列表 空列表不是 None 'is not None' 类似 != None
== tests value where is tests to see if they are the same object
TA贡献1818条经验 获得超7个赞
因为 [] 是空列表,确实不是 None 啊。if 的条件如果是 0, 空字符串 '', 空列表 [],布尔值 False,None,都会被判断为 False,条件语句不执行。
TA贡献1873条经验 获得超9个赞
xx is not None = xx != Noneif xx = if xx != None and xx != '' and xx != False and xx != 0 and xx != [] and xx !={} and ...
TA贡献1936条经验 获得超7个赞
题主需要了解下falsy和False的区别, () [] None False 这些都是 Falsy的,但Falsy不只有这些。What is Truthy and Falsy in python? How is it different from True and False?
TA贡献1865条经验 获得超7个赞
None 是一个特殊的对象,而一个对象的布尔值是由__bool__和__len__ 特殊方法决定的。 None更多的时候作为sentinel对象使用,比如判断循环是否执行。
添加回答
举报
