Python 逻辑运算符 and or not

记住三句话,所有搞定变量

and:  与运算,当全部条件都为True时返回True运算符

or:    或运算,当其中一个条件为True时返回True

not:    非运算,当条件为True时返回False,条件为False时返回True

 

三者之间的优先级:

优先级:() > not > and > or

 

注:逻辑运算符用于操做 bool 类型的变量、常量或表达式,逻辑运算的返回值也是 bool 值。

相关文章
相关标签/搜索