逻辑运算符运算

1、and、or、not的优先级

优先级从大到小:()>not>and>or

2、输出返回值时,x or y,x为True,则返回x

print(1 or 2) 返回1
print(3 or 2) 返回3

3、输出反回值时,x and y,x为True,则返回Y(and与or 相反

print(1 and 2) 返回2
print(3 and 2) 返回2

猜你喜欢

转载自www.cnblogs.com/gldlife/p/9161611.html