An is not None and if an in python: difference

res=requests.get("https://www.zhipin.com/gongsi/_zzz_c101010100_iy100014_t801_s301/",headers=headers)
turn=etree.HTML(res.text).xpath("//div[@class="page"]/a[contains(@ka,"page-next")]/@href")
turn
[]
next_page is not None
Traceback (most recent call last):
  File "<input>", line 1, in <module>
NameError: name "next_page" is not defined
turn is not None
True
turn
[]
if turn:
    print("sss")
    
turn is not None
True
turn is  None
False


 is not None is not None 

May.09,2022

because the xpath you wrote does not match the data, you are returned an empty list, not None' is not None'! = None
= tests value where is tests to see if they are the same object


because [] is an empty list, it is not None ah. If the condition of
if is 0 , empty string ', empty list [] , Boolean value False , None , it will be judged as False , and the conditional statement will not be executed.


xx is not None = xx! = None
if xx = if xx! = None and xx =''and xx! = False and xx! = 0 and xx! = [] and xx! = {} and.


the subject needs to know the difference between falsy and False , () [] None code these are all code , but not all of them. python-how-is-it-different-from-true-and-false" rel=" nofollow noreferrer "> What is Truthy and Falsy in python? How is it different from True and False?


None is a special object, and the Boolean value of an object is determined by _ _ bool__ and _ _ len__ special methods. None is more often used as a sentinel object, such as determining whether a loop is executed.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b41e46-2c5f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b41e46-2c5f9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?