'''
try :
except exception:
finally:
'''
try:
num = int(input("please input an number"))
print(100/num)
except:
print("except")
finally:
print("exit")
错误信息:
'''
try :
except exception:
finally:
通过异常捕获,对异常进行实例化 获取错误信息
'''
try:
num = int(input("please input an number"))
print(100/num)
except Exception as e:
print("except")
print(e)
finally:
print("exit")
手动触发异常z:
raize 异常名
自定义异常:
继承父类异常