有没有办法让python检查多个值?

时间:2018-01-05 17:55:31

标签: python-3.x dictionary if-statement

有没有办法让python检查&#34的多个值;不等于"?像:

if len(dict) != 2 or 4 or 8 or 16 or 32:
    do_something()

1 个答案:

答案 0 :(得分:0)

使用set

if len(dict) not in {2, 4, 8, 16, 32}:
    do_something()