s=raw_input("Input your age:")
if s=="":
raise Exception("Input must no be empty.")
try:
i=int(s)
except ValueError:
print "Could not convert data to an integer."
except:
print "Unknown exception!"
else:
print "You are %d "%i,"years old"
finally:#Clean up action
print "Goodbye!"
异常处理
最新推荐文章于 2024-04-06 01:43:21 发布