Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我今天在编写一些 Python 时意识到可以将不等式运算符编写为a!=bor not a==b。这让我很好奇:
a!=b
not a==b
==
__eq__()
!=
__ne__()
not ==
注意你的括号。
>>> not "test" == True True >>> not "test" and True False
==优先于not. 但是not和and具有相同的优先级,所以
not
and
Python 运算符优先级