查看以下网站:
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 中,<>不再存在。
