Python不等于运算符 [英] Python not equal operator
问题描述
我来自ac风格语言,因此我很自然地使用!=
来表示不相等,但是当我使用Python时,从阅读的文档中我学到了为此使用了<>
运算符。
I come from a c style languages, so I am natural in using !=
as not equal, but when I came to Python, from the documentation I read, I learned that for this purpose the <>
operator is used.
最近,我已经看到很多使用!=
的代码,所以我的问题是是否其中之一是
Recently, I have seen a lot of code using !=
, so my question is if one of them is preferred over the other or is one of them deprecated.
此外,我想知道它们之间是否有任何区别。
Also, I would like to know if there is any difference between them.
推荐答案
Python 2支持两者,在python 3中,<>
运算符
Python 2 supports both, in python 3 the <>
operator has been removed.
两者之间没有区别,但是 !=
是首选形式。
There is no difference between the two, but !=
is the preferred form.
这篇关于Python不等于运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!