1,python异常处理
常用的用法:
try:
pass
except Exception as e:
pass
else:
pass
finally:
pass
2,python异常处理例子
try:
a = 10/0
except Exception as e:
print(e)
else:
print('ok')
finally:
print('我就执行了')
try 捕捉异常,如果捕捉到异常将异常内容给e,如果没有捕捉到异常,则输出else语句。
最后输出finally语句。