zoukankan      html  css  js  c++  java
  • 判断and ,or

    and 和 or 是条件 与和或,记住一条,and 是两边同时都满足,or  是只有满足一个条件就成立。

    # print(1 or False)  #条件1成立,条件2不成立。打印条件1                                                   #返回: 1
    # print(False or 1) #条件1不成立,条件2成立打印条件2 #返回: 1
    # print(1 or 2) #条件1,2都成立则打印,已经满足的条件1,不会继续往后判断 #返回: 1
    # print(False or False) #条件1,2都不成立打印False #返回: False


    #
    # print(1 and False) #条件1成立,条件2不成立。and是需要同时满足,打印条件2 #返回: False
    # print(False and 1) #条件1不成立,条件2成立. #返回: False
    # print(1 and 2) #件1,2都成立则打印,后面一个判断为true的条件 #返回: 2
    # print(False and False) #条件1,2都不成立打印False #返回: False

    ***!!!
    print(0 and 2) #返回0,理解因为0 and 2判断为false,所以返回0,0就代表false。


    运算符优先级:()> not > and > or 同一个优先级,从左至右依次计算。
    例如:同时出现多个and,或者or ,就按照从左至右依次计算
    print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8)                             #返回:False


    先写在这里后面解释:
    int ---> bool 非0即True,0为False
    # bool---> int True 1 False 0





  • 相关阅读:
    Choosing the Type at Runtime
    User-Defined Components Must Be Capitalized
    Computed property names
    Controlled Components
    Handling Event
    State
    props
    Functional and Class Components
    招聘漂亮的员工
    Spread Syntax
  • 原文地址:https://www.cnblogs.com/sunny7/p/8684702.html
Copyright © 2011-2022 走看看