逻辑运算符

not,and,or

not:将紧跟其后的那个值取反
例:not 3<5 (false)
not false (True)
not 1 (false)

and:连接左右两侧的判断
例:
3<5 and 5>1 (True)
21 and 5>1 (false)
True and false (false)
3<5 and 8>5 and True and 5
5 (false)
ps:两侧都为真的情况下是真,任意一侧为假即为假。(同真为真,一假为假)

or:连接左右两侧的判断
例:
3<5 or 3>5 (True)
2==1 or 3>5 (false)
True or false (True)
3>5 or 5>8 or True or false (True)
ps:两侧都为假的情况下是假,任意一侧为真即为真。(同假为假,一真为真)

优先级:not>and>or

posted @ 2020-03-06 19:07  江湖有梦  阅读(212)  评论(0编辑  收藏  举报