• 重新梳理Python基础(6)


    1. 整理的一些符号(前三个在java和c中是不这样表达的,用&&、||、!表达)
      • and
      • or
      • not
      • != (not equal)
      • == (equal)
      • >= (greater-than-equal)
      • <= (less-than-equal)
      • True
      • False
    View Code
    # _*_ coding:utf-8 _*_
    print (True and False), False
    print (False and True), False
    print (1 == 1 and 2 == 1), False
    print ("test" == "test"), True
    print (1 == 1 or 2 != 1), True
    print (True and 1 == 1), True
    print (False and 0 != 0), False
    print (True or 1 == 1), True
    print ("test" == "testing"), False
    print (1 != 0 and 2 == 1), False
    print ("test" != "testing"), True
    print ("test" == 1), False
    print not (True and False), True
    print not (1 == 1 and 0 != 1), False
    print not (10 == 1 or 1000 == 1000), False
    print not (1 != 10 or 3 == 4), False
    print not ("testing" == "testing" and "Zed" == "Cool Guy"), True
    print not (1 == 1 and not ("testing" == 1 or 1 == 0)), False
    print not ("chunky" == "bacon" and not (3 == 4 or 3 == 3)), True
    print (3 == 3 and not ("testing" == "testing" or "Python" == "Fun")), False
    print "test" and "test" #输出test,布尔操作符and和or会输出操作符两侧的内容,而不是True和False
    print "test" or "test"
    print not ("test" and "test") 
    View Code
    False False
    False False
    False False
    True True
    True True
    True True
    False False
    True True
    False False
    False False
    True True
    False False
    True True
    False False
    False False
    False False
    True True
    False False
    True True
    False False
    test
    test
    False

    注意"test" and "test" = "test",而不是1。or也是如此

  • 相关阅读:
    html总结:背景图片拉伸
    html总结:表格中的文字居中
    html总结:float实现span和input输入框同行
    servlet总结:Servlet基础
    js总结:JavaScript入门
    河北科技创新平台年报系统涉众分析
    确定业务问题的范围-上下文的范围模型
    问题账户需求分析
    Struts2------OGNL表达式
    Struts入门
  • 原文地址:https://www.cnblogs.com/dollarzhaole/p/2965668.html
Copyright © 2020-2023  润新知