!=和<>之间是否有区别? Python中的运算符? [英] Is there a difference between != and <> operators in Python?

查看:196
本文介绍了!=和<>之间是否有区别? Python中的运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试搜索,但找不到关于<>运算符的更多信息.

I tried searching but could not find much about the <> operator.

https://www.tutorialspoint.com/python/python_basic_operators.htm 提到<>是与!=运算符相似",没有说明有什么不同或有什么不同.

https://www.tutorialspoint.com/python/python_basic_operators.htm mentions that <> is "similar" to the != operator and does not say what is different or how it is different.

我的测试似乎表明它是相同的:

My tests seem to show it is the same:

a = 2, b = 3
>>> a != b
True
>>> a <> b
True
>>> b = 2
>>> a != b
False
>>> a <> b
False

任何帮助您理解这一点的人将不胜感激.

Any help to understand this would be appreciated.

推荐答案

python文档表示它们是等效的.

The python documentation says that they are equivalent.

比较运算符<>!=是同一运算符的备用拼写. !=是首选拼写; <>过时了.

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

<>运算符已从Python 3中删除 .

The <> operator has been removed from Python 3.

这篇关于!=和&lt;&gt;之间是否有区别? Python中的运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆