Python 2 REPL 的以下输出让我感到困惑:
>>> 15>10==True
False
>>> 15>1==True
True
>>> 15>2==True
False
>>> 15>False
True
If15>10==True被评估为(15>10)==True表达式将简化为print True==True,这显然评估为True。If15>10==True被评估为15>(10==True)表达式简化为15>Falsewhich 也评估为True。这两种解释都与表达式 ( False) 的实际值相矛盾。
我可以理解15>1==True评估 to Truesince1==True是正确的,但对我来说没有任何解释是15>10==True有意义的。
摘要:在 Python 2 中,为什么15>10==True计算结果为False?