Python,为什么要使用elif关键字? [英] Python, why elif keyword?

查看:66
本文介绍了Python,为什么要使用elif关键字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始Python编程,我想知道elif关键字.

I just started Python programming, and I'm wondering about the elif keyword.

我在使用else if之前曾经使用过的其他编程语言.有谁知道为什么Python开发人员添加了额外的elif关键字?

Other programming languages I've used before use else if. Does anyone have an idea why the Python developers added the additional elif keyword?

为什么不呢?

if a:
    print("a")
else if b:
    print("b")
else:
    print("c")

推荐答案

最有可能是语法糖.就像Visual Basic的Wend.

Most likely it's syntactic sugar. Like the Wend of Visual Basic.

这篇关于Python,为什么要使用elif关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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