python实例 异常处理

#! /usr/bin/python
s=input("Input your age:")
if s =="":
    raise Exception("Input must no be empty.")

try:
    i=int(s)
except Exception as err:
    print(err)
finally: # Clean up action
    print("Goodbye!")

原文地址:https://www.cnblogs.com/fanweisheng/p/11243870.html