要么
如果其中一个参数是真实的,则评估第一个 truthy 参数。如果两个参数都为假,则求值为第二个参数。
x = True
y = True
z = x or y # z = True
x = True
y = False
z = x or y # z = True
x = False
y = True
z = x or y # z = True
x = False
y = False
z = x or y # z = False
x = 1
y = 1
z = x or y # z = x, so z = 1, see `and` and `or` are not guaranteed to be a boolean
x = 1
y = 0
z = x or y # z = x, so z = 1 (see above)
x = 0
y = 1
z = x or y # z = y, so z = 1 (see above)
x = 0
y = 0
z = x or y # z = y, so z = 0 (see above)
上例中的 1
可以更改为任何 truthy 值,0
可以更改为任何 falsey 值。