在python中,任何物件都可以判斷其真假值:True,False
在if或while條件判斷中,下面的情況值為False:
1.None 3.數值為0的情況,如:0,0.0,0j
4.所有空序列,如:'',(),[]
5.所有空mapping,如:{}
6.instances of user-defined classes, if the class defines a __bool__() or __len__() method,
when that method returns the integer zero or bool value False.
many types are always true.
1或True表示true
運行結果:
or 0 = 2
or 10 = 10
or 0 = 2or 10 = 10##############################################
x and y -> if x is false,then x, else y
and 0 = 0
and 10 = 0
and 0 = 0
######## #################################
not x -> if x is false,then True,else False
not 2 = False
not 0 = True
>>>