Python boolean expression and or

后端 未结 4 2159
小蘑菇
小蘑菇 2020-12-01 21:17

In python if you write something like

foo==bar and spam or eggs

python appears to return spam if the boolean statement is true and eggs oth

4条回答
  •  自闭症患者
    2020-12-01 21:35

    Try using parentheses to make the expression non-ambiguous. The way it is, you're getting:

    (foo == bar and spam) or eggs
    

提交回复
热议问题