首页 > 其他 > 详细

逻辑运算符

时间:2020-03-06 20:06:37      阅读:56      评论:0      收藏:0      [点我收藏+]

not,and,or

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

and:连接左右两侧的判断
例:
3<5 and 5>1 (True)
2==1 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

逻辑运算符

原文:https://www.cnblogs.com/bailongcaptain/p/12430244.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!