python 3.3 try..catch 小例

s=input("input your age:")
if s=="":
	raise Exception("input must not be empty.")

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


运行结果:


你可能感兴趣的:(python 3.3 try..catch 小例)