成都创新互联网站制作重庆分公司

Python之逻辑运算符

'''
逻辑运算 : 
    且 : and------全真则真,一假则假
    或 : or------一真则真,全假则假
    非 : not-----取反
逻辑运算优先级 :
    () > not > and > or
特殊逻辑运算(指见于面试题中,开发中及其少见) : 
    num1 or num2    #当num1 == 0时,返回num2,num1 != 0时返回num2;and运算与之完全相反;
例题分析 : 
例题一:
# False or  True or        ( False)           or False
#        True    or         False             or False
#                True                         or False
#                              True
  1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
例题二:
#8 or (  4  ) or (  0  ) or (  7  ) 
#   8         or    0    or    7
#             8          or    7
#                        8
 8 or 3 and 4 or 2 and 0 or 9 and 7
'''

网站名称:Python之逻辑运算符
分享地址:http://cxhlcq.com/article/jiochh.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部