这是什么“如果”声明的意思? [英] What does this "if" statement mean?
本文介绍了这是什么“如果”声明的意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在示例Hadoop reduce程序中,存在这样的if语句。我想知道当
在if语句中使用两次相同的变量a时意味着什么,如下所示
In an example Hadoop reduce program, such an "if" statement exists. I am wondering what it means when the same variable "a" is used twice in the "if" statement, as follows
if a and a == b:
print "It is working!"
推荐答案
它将测试是否相等( a == b
)仅当 a
是真的时。
It will test for equality (a == b
) only if a
is truthy.
它可以是改写为
if a:
if a == b:
print("It is working!")
注意运算符优先级:它是 不是 等于 if(a和a)== b
。
Note the operator precedence: it's not equal to if (a and a) == b
.
这篇关于这是什么“如果”声明的意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文