• 重新梳理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也是如此

  • 相关阅读:
    redis中文API
    基于redis的分布式锁
    redis安装使用配置
    windows常用命令
    curl命令详解
    linux远程连接
    memcache在大型网站的应用策略
    缓存使用的一些注意事项
    记录memcache分布式策略及算法
    U盘安装Centos7.0图解
  • 原文地址:https://www.cnblogs.com/dollarzhaole/p/2965668.html
Copyright © 2020-2023  润新知