Python 关键字 else
定义和用法
else关键字在条件语句(if语句),当条件为假时
else关键字,也可以在try...except 块中使用,见下面的例子。
更多实例
实例
在try ... except块中使用else关键字来定义在没有引发错误时要执行的操作:x = 5
try:
x > 10
except:
print("Something went wrong")
else:
print("The 'Try' code was executed without raising any errors!")
运行实例»相关页面
if关键字。
elif关键字。
在Python条件教程中阅读有关条件语句的更多信息。 