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.