不,它们不相等。例如:
>>> mode = float('nan')
>>> allowed_modes = [mode]
>>> any(mode == allowed_mode for allowed_mode in allowed_modes)
False
>>> mode in allowed_modes
True
对于list,tuple,set,frozenset,dict或collections.deque等容器类型,该表达式x in y
等效于any(x is e or x == e for e in y)
。