当前位置: 代码迷 >> 综合 >> python 与或非 and or not 记录
  详细解决方案

python 与或非 and or not 记录

热度:41   发布时间:2024-02-21 13:08:08.0

1.and

a and b :如果a为false则返回false,否则返回b

实例:3 and 8 —>8

          0 and 9  —>0

也就是说只有a为false即0时返回false0,其余都返回b的值

2.or

a or b:如果a为true则返回true,否则返回b

实例:99 or 0 —>99

           0 or 4  —>4

也就是说a为非0值就返回a的值,但是若a为0就返回b的值

3.not

not a:如果a为true则返回false

  相关解决方案