!=和<>有什么区别? [英] What is the difference between != and <>?
问题描述
也许这是一个相当新手的问题,但我很好奇.我已经尝试过搜索,但是我想我缺少正确搜索的正确术语.
Perhaps this is a rather newbie-ish question, but I'm curious. I have tried searching for it, but I suppose I lack the correct terminology to search properly.
!=
和<>
之间的差异.
在再次搜索不平等"时,我发现其中一个讨论了not ==
和!=
,但没有讨论<>
.
On searching again, "inequality", I found one that discusses not ==
and !=
, but nothing about <>
.
推荐答案
In Python 2.x, <>
is equivalent to !=
, as described in the documentation:
<>和!=的形式是等效的;为了与C保持一致,最好使用!=;其中下面提到的!=也被接受<>. <>拼写被认为是过时的.
The forms <> and != are equivalent; for consistency with C, != is preferred; where != is mentioned below <> is also accepted. The <> spelling is considered obsolescent.
在Python 3.x中,<>
已被删除.再次,文档说:
In Python 3.x, <>
has been removed. Again, the documentation says:
已删除语法
....
已删除<>(改用!=).
Removed <> (use != instead).
这篇关于!=和<>有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!