if if else if if else语句? [英] If vs. else if vs. else statements?

查看:192
本文介绍了if if else if if else语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是:

if statement:
if statement:

if statement:
elif statment:

if statement:
else statement:

相同?
如果没有,有什么区别?

the same? If not, what's the difference?

推荐答案

不,它们不一样。

if statement:
if statement: 

如果第一个语句为真,则其代码将执行。另外,如果第二个语句为真,则其代码将执行。

If the first statement is true, its code will execute. Also, if the second statement is true, its code will execute.

if statement:
elif statment:

如果第一个没有,第二个块只会在这里执行,第二个检查是真的。

The second block will only execute here if the first one did not, and the second check is true.

if statement:
else:

如果第一个语句为真,则执行第一个语句,如果第一个语句为假,则执行第二个语句。

The first statement will execute if it is true, while the second will execute if the first is false.

这篇关于if if else if if else语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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