【发布时间】:2016-04-27 12:22:31
【问题描述】:
python 新手,我无法让以下简单的复合 if 语句起作用
if A == B & C >= D & C <= E:
每个子语句都可以单独工作,但我似乎无法将它们组合在一个命令中。
【问题讨论】:
-
&是 binary bitwise operator,而不是逻辑上的and。
标签: python python-3.x
python 新手,我无法让以下简单的复合 if 语句起作用
if A == B & C >= D & C <= E:
每个子语句都可以单独工作,但我似乎无法将它们组合在一个命令中。
【问题讨论】:
& 是 binary bitwise operator,而不是逻辑上的 and。
标签: python python-3.x
if A == B and C >= D and C <= E:
【讨论】:
& 是 binary bitwise operator,而不是您要查找的 boolean operator and。
这样做:
if A == B and C >= D and C <= E:
【讨论】: