不,它们不相等。例如:
>>> mode = float('nan')>>> allowed_modes = [mode]>>> any(mode == allowed_mode for allowed_mode in allowed_modes)False>>> mode in allowed_modesTrue有关更多详细信息,请参阅成员资格测试操作,包括以下语句:
对于list,tuple,set,frozenset,dict或collections.deque等容器类型,该表达式
x in y等效于any(xis e or x == e for e in y)。



