Python逻辑运算符有哪些?

Python逻辑运算符中有三种 and 、 or 、not

【1】and 逻辑: “ 两真为真才是真 "--true

true  and  true  ---true ---两真为真才是真
true  and  false ---false
false and  false ---false
false and  true  ---false

用例图:


【2】or 逻辑:“ 两假为假才是假 ”---false

true  or  true   ---true
true  or  flase  ---true
flase or  true   ---true
flase or  flase  ---flase ---两假为假才是假

用例图:


【3】not  逻辑:“ 真变假 假变真 ”
not true  ---falas  ---真变假
not falas  ---true  ---假变真

运算中优先级别:() >not >and >or

猜你喜欢

转载自blog.csdn.net/qq_44361142/article/details/127007346