Python学习-异常处理

Exception为所有异常类的父类,可以捕获所有异常

def div(a,b):
    return a/b
try:
    r=div('er',3)
except Exception as e:
    print(e.args)
else:
    print('结果是',r)
finally:
    print('finally')

猜你喜欢

转载自www.cnblogs.com/pennyxiaoxiantu/p/11050525.html
今日推荐