码迷,mamicode.com
首页 > 其他好文 > 详细

逻辑运算符运算

时间:2018-06-09 23:20:08      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:not   print   逻辑   运算   优先   str   返回   逻辑运算   优先级   

1、and、or、not的优先级

优先级从大到小:()>not>and>or

2、输出返回值时,x or y,x为True,则返回x

print(1 or 2) 返回1
print(3 or 2) 返回3

3、输出反回值时,x and y,x为True,则返回Y(and与or 相反

print(1 and 2) 返回2
print(3 and 2) 返回2

逻辑运算符运算

标签:not   print   逻辑   运算   优先   str   返回   逻辑运算   优先级   

原文地址:https://www.cnblogs.com/gldlife/p/9161611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!