Python/gloss python else
来自菜鸟教程
<languages />
如果没有其他Python
Else
The else 关键字可捕获不符合上述条件的任何内容。
例
a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
在这个例子中 a 大于 b ,因此第一个条件不成立, elif 条件不成立,所以我们去 else 并打印到屏幕上“ a大于b”。
您也可以
else
没有
elif
例
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")