This question already has answers here:
“x not in y” or “not x in y”
                                
                                    (6个答案)
                                
                        
                                2年前关闭。
            
                    
我尝试这样做:

a = [1,2,3]
if 68 not in a:
    print 'missing'

a = [1,2,3]
if not 68 in a:
    print 'missing'


输出是相同的。但是我怀疑两者在逻辑上是否相同。这在逻辑上是一样的吗?谢谢

最佳答案

是的,它们是相同的。这与它们的字面意思相同。

甚至内部比较成本也可能相同。

关于python - 这在逻辑上是相同的吗? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43446435/

10-11 15:04
查看更多