Python(或通用编程).为什么使用<>而不是!=,并且存在风险吗? [英] Python ( or general programming ). Why use <> instead of != and are there risks?

查看:158
本文介绍了Python(或通用编程).为什么使用<>而不是!=,并且存在风险吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为,如果我理解正确,a <> b在功能上与a != b完全相同,并且在Python not a == b中完全相同,但是是否有理由在其他版本上使用<>?对于Python新手来说,我知道一个常见的错误是认为not a is ba != bnot a == b相同.

I think if I understand correctly, a <> b is the exact same thing functionally as a != b, and in Python not a == b, but is there reason to use <> over the other versions? I know a common mistake for Python newcomers is to think that not a is b is the same as a != b or not a == b.

  1. <>是否会发生类似的误解,或者功能完全相同?
  2. 它在内存,处理器等方面的成本是否更高?
  1. Do similar misconceptions occur with <>, or is it exactly the same functionally?
  2. Does it cost more in memory, processor, etc.

Python 2中的

推荐答案

<>!=的确切同义词-没有理由使用它,除了无用的异质性(样式问题)之外也没有缺点. ).长期以来一直不鼓励这样做,现在已在Python 3中将其删除.

<> in Python 2 is an exact synonym for != -- no reason to use it, no disadvantages either except the gratuitous heterogeneity (a style issue). It's been long discouraged, and has now been removed in Python 3.

这篇关于Python(或通用编程).为什么使用&lt;&gt;而不是!=,并且存在风险吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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