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 NoneTraceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'next_page' is not defined
turn is not NoneTrueturn
[]if turn:
print('sss')
turn is not NoneTrueturn is NoneFalse为啥这个是空 写is not None 是对的?这个is not None 什么时候用?
1 回答
胡说叔叔
TA贡献1804条经验 获得超8个赞
因为你写的xpath没有匹配到数据,所以给你返回的是一个空的列表 空列表不是 None 'is not None' 类似 != None
== tests value where is tests to see if they are the same object
添加回答
举报
0/150
提交
取消