您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python开发_python中的Boolean运算和真假值

5b51 2022/1/14 8:24:17 python 字数 2996 阅读 622 来源 www.jb51.cc/python

python开发_python中的Boolean运算和真假值

概述

python中的真假值

2.False

3.zero of any numeric type,<span style="color: #0000ff;">for example,0.0<span style="color: #000000;">,0j.

4.any empty sequence,<span style="color: #800000;">''<span style="color: #000000;">,(),[].

5.any empty mapping,<span style="color: #0000ff;">for<span style="color: #000000;"> example,{}.

6.instances of user-defined classes,<span style="color: #0000ff;">if the <span style="color: #0000ff;">class defines a <span style="color: #800080;">bool() <span style="color: #0000ff;">or <span style="color: #800080;">len() method,when that method returns the integer zero <span style="color: #0000ff;">or bool value False. [1<span style="color: #000000;">]

All other values are considered true — so objects of many types are always true.

Operations <span style="color: #0000ff;">and built-<span style="color: #0000ff;">in functions that have a Boolean result always <span style="color: #0000ff;">return 0 <span style="color: #0000ff;">or False <span style="color: #0000ff;">for false <span style="color: #0000ff;">and 1 <span style="color: #0000ff;">or True <span style="color: #0000ff;">for true,unless otherwise stated. (Important exception: the Boolean operations <span style="color: #0000ff;">or <span style="color: #0000ff;">and <span style="color: #0000ff;">and always <span style="color: #0000ff;">return one of their operands.)

总结:

效果:

总结

以上是编程之家为你收集整理的python开发_python中的Boolean运算和真假值全部内容,希望文章能够帮你解决python开发_python中的Boolean运算和真假值所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶