inp = input(">>>>>")
try:
r = int(inp)
print(r)
except Exception as e:
print(e)
else:
print("try内代码没有异常就执行else")
finally:
print("上面执行结果对错,我都执行")
主动触发异常raise
try:
raise KeyError('错误')
except Exception as e:
print(e)
else:
print("try内代码没有异常就执行else")
finally:
print("上面执行结果对错,我都执行")