Skip to main content
 首页 » 编程设计

python之python 中的 != 和 > 比较运算符有什么区别

2025年05月04日9jiqing9006

查看以下网站:
TutorialPoint

标题下有Python Comparison Operators:

你会看到写着!=类似于 <>运算符
甚至我测试了这个东西。

那么这两个比较运算符的主要区别是什么?

也有文档说它们是相似的,而不是相同的。这两个比较运算符的比较标准是否不同?

请您参考如下方法:

在 2.7 中,它们是相同的。来自 the documentation :

The comparison operators <> and != are alternate spellings of the same operator. != is the preferred spelling; <> is obsolescent.

在 3.X 中,<>不再存在。