概述
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运算和真假值所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧