“<>"在Python中是什么意思? [英] What does `<>` mean in Python?
问题描述
我正在尝试在Python 3.3中使用旧的库(可追溯到2003年!).导入时,Python抛出错误,因为源文件中有<>
标志,例如:
I'm trying to use in Python 3.3 an old library (dating from 2003!). When I import it, Python throws me an error because there are <>
signs in the source file, e.g.:
if (cnum < 1000 and nnum <> 1000 and ntext[-1] <> "s":
...
我想这是该语言中已被废弃的标志.
I guess it's a now-abandoned sign in the language.
这到底是什么意思,我应该用哪个(较新的)符号代替?
What exactly does it mean, and which (more recent) sign should I replace it with?
推荐答案
这意味着不等于.它取自ABC
(python的前身),请参见此处:
It means not equal to. It was taken from ABC
(python's predecessor) see here:
x < y, x <= y, x >= y, x > y, x = y, x <> y, 0 <= d < 10
订单测试(<>
表示'不等于')
我相信ABC
是从Guido开始使用的Pascal语言中获得的.
I believe ABC
took it from Pascal, a language Guido began programming with.
现在已在Python 3中将其删除.改用!=
.如果您疯狂,则可以使用
It has now been removed in Python 3. Use !=
instead. If you are CRAZY you can scrap !=
and allow only <>
in Py3K using this easter egg:
>>> from __future__ import barry_as_FLUFL
>>> 1 <> 2
True
这篇关于“<>"在Python中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!