python逻辑运算符规则
逻辑运算符:or and not
优先级:()>not>and>or
举例子:
Print(2>1 and 1<4 or 2<3 and 9>6 or 2<4 and 3<2 )
根据优先级,有优先的先算优先,相同优先级的从左往右计算。所以上面的为:
2>1 and 1<4 = true
2<3 and 9>6 =true
2<4 and 3<2 = false
所以变为: true or true or false = true
逻辑运算符:or and not
优先级:()>not>and>or
举例子:
Print(2>1 and 1<4 or 2<3 and 9>6 or 2<4 and 3<2 )
根据优先级,有优先的先算优先,相同优先级的从左往右计算。所以上面的为:
2>1 and 1<4 = true
2<3 and 9>6 =true
2<4 and 3<2 = false
所以变为: true or true or false = true