Python 如何使用“多个”;不在「;在if语句中?

Python 如何使用“多个”;不在「;在if语句中?,python,python-3.x,Python,Python 3.x,是否可以在if语句中使用多个not in for each_id in lst: if "Audiobook" not in (driver.find_element_by_id('productDetailsTable').text) & "a-popover-root" not in (driver.page_source): titles.append(driver.find_element_by_id('title').text) 上面的代码对我不起作用

是否可以在
if
语句中使用多个
not in

for each_id in lst:
    if "Audiobook" not in (driver.find_element_by_id('productDetailsTable').text) & "a-popover-root" not in (driver.page_source):
        titles.append(driver.find_element_by_id('title').text)
上面的代码对我不起作用,我已经尝试了多次,但都无法理解


非常感谢您的帮助。

您需要使用逻辑“and”(
),而不是按位“and”(
&
):


您需要使用逻辑“and”(
),而不是按位“and”(
&
):


使用逻辑and即and代替&

使用逻辑and即and代替&

&
是一种按位操作,几乎肯定不是您需要的。我猜您想使用
代替
&
?您刚刚做到了。即使逻辑AND是
,但not
&
&
是一种按位操作,几乎肯定不是您需要的。我猜您想使用
而不是
&
?您刚刚做到了。即使逻辑AND是
,但不是
&
if "Audiobook" not in (driver.find_element_by_id('productDetailsTable').text) and "a-popover-root" not in (driver.page_source):