PyTricks-Differebt ways to test multiple flags at once in

x, y, z = 0, 1, 0

if x == 1 or y == 1 or z == 1:
    print('passed')
if 1 in (x, y, z):
    print('passed')
if x or y or z:
    print('passed')
if any((x, y, z)):
    print('passed')

上面的公式效果是等效的。

原文地址:https://www.cnblogs.com/c-x-a/p/11313093.html