python 逻辑运算and or
and:与运算,定义变量x,y
x and y
如果x,y 为真,返回y值,只要x,y有一为假,结果为0或false
x or y,只要有一值为真,结果为真:
Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a=10
>>> b=20
>>> a and b
20
>>> a or b
10
>>> c=0
>>> c and b
0
>>> c or b
20
>>> a and c
0
>>> d=False
>>> a and d
False
>>> c or d
False
>>>