zoukankan      html  css  js  c++  java
  • 布尔操作符

       and 、 or 、not  三个布尔操作符号用于比较布尔值

      1.二元布尔操作符

       如果两个布尔值都为True, and操作符就将表达式求值为True,否则求值为False;如下:

    >>> True and True
    True
    >>> True and False
    False
    >>> 

       以下为and的操作符的比较:

    表达式                   求值
    True and True           True
    True and False          False
    False and True          False
    False and False         False

       or:只要有一个布尔值为真,or操作符就将表达式求值为True,如果都是False,则结果为False;

    表达式             求值为
    True or True      True 
    True or False     True 
    False or False    True 
    False or False    False

     2.not操作符

       区别:和and和or不同,not操作符只作用域一个布尔值;

       not操作符求值为相反的布尔值

    >>> not True
    False
    >>> not not not not True   
    True
    表达式        求值  
    not True    False
    not False   True

    待补充~

  • 相关阅读:
    sublime text添加snippet
    python __globals__, __file__
    Zen of Python
    Python的魔法函数之
    tornado session
    sqlalchemy学习
    自控力
    无需编译、快速生成 Vue 风格的文档网站
    python描述符理解
    python property理解
  • 原文地址:https://www.cnblogs.com/FlameLuo/p/9550911.html
Copyright © 2011-2022 走看看