zoukankan      html  css  js  c++  java
  • 重新梳理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也是如此

  • 相关阅读:
    github访问慢
    vue的图片裁剪上传vue-cropper
    vue动态设置路由重定向
    vue移动端预览pdf
    Vue项目中给路由跳转加上进度条nprogress
    IDEA收藏夹迁移
    Go语言基础语法(一)
    Go语言开发环境安装
    Windows上实现iOS APP自动化测试:tidevice + WDA + facebook-wda / appium
    配置Linux主机名
  • 原文地址:https://www.cnblogs.com/dollarzhaole/p/2965668.html
Copyright © 2011-2022 走看看