python05_运算符优先级

python表达式:一个或多个操作数通过操作符组合而成

运算符分类:

python05_运算符优先级
1)算术运算符
python05_运算符优先级
python05_运算符优先级
2)赋值运算符
python05_运算符优先级
3)比较运算符
python05_运算符优先级
可以多个运算符连用,如10<x<30
4)逻辑运算符
python05_运算符优先级python05_运算符优先级
短路运算原则:
如果表达式后面是or,前面为true则不继续运算
如果表达式后面是and,前面为false则不继续运算
如果表达式中包含not,not一定是与后面的表达式结合
等价结果:
exp1 or exp2 and exp3
res = exp1
if bool(res) == False:
res = exp2:
if bool(res) == True
res = exp3

5)成员关系运算符
python05_运算符优先级
6)对象实例测试运算符
python05_运算符优先级
7)位运算符
python05_运算符优先级

运算符优先级
python05_运算符优先级
and,or同级=>短路运算