当我看到这个问题的答案时,我发现我不明白自己的答案.
我真的不明白这是如何被解析的.为什么第二个示例返回False?
>>> 1 in [1,0] # This is expected
True
>>> 1 in [1,0] == True # This is strange
False
>>> (1 in [1,0]) == True # This is what I wanted it to be
True
>>> 1 in ([1,0] == True) # But it's not just a precedence issue!
# It did not raise an exception on the second example.
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
1 in ([1,0] == …Run Code Online (Sandbox Code Playgroud)