python多个and or运算顺序

在不添加括号的情况下,多个and or 进行逻辑操作时,and运算符的优先级大于 or

  • 输入:1 and 0 or 1 and 0
  • 运算顺序
    a. 先运算所有的and运算,and运算部分先后,存在一个假即为假
    b. 再运算所有的or,运算不分顺序,存在一个真即为真。
  • 上述运算结果为:
    a. 0 or 0
    b. 结果为

猜你喜欢

转载自blog.csdn.net/u013894391/article/details/104287094