美文网首页
Test multiple flags at once

Test multiple flags at once

作者: import_hello | 来源:发表于2018-10-12 07:10 被阅读0次
# Different ways to test multiple
# flags at once in Python
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')

# These only test for truthiness:
if x or y or z:
    print('passed')

if any((x, y, z)):
    print('passed')

相关文章

网友评论

      本文标题:Test multiple flags at once

      本文链接:https://www.haomeiwen.com/subject/xykboftx.html