Python中的逻辑运算

1, 在没有()的情况下not 优先级高于 and,and优先级高于or,即优先级关系为( )>not>and>or,同一优先级从左往右计算。 () > not > and > or

2, x or y , x为真,值就是x,x为假,值是y; x and y, x为真,值是y,x为假,值是x。(这一条需要结合第三条来看)

3.0/""/None 都是假,其他为真.即:空为假,非空为真.

猜你喜欢

转载自www.cnblogs.com/DoingBe/p/9270209.html