[原]Python 简单异常处理
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: # It is useful for code that must be executed if the try clause does not raise an exception print "You are %d" % i," years old" finally: # Clean up action print "Goodbye!" raw_input("press any key to continue...")
作者:svitter 发表于2014-5-2 23:28:04 原文链接
阅读:14 评论:0 查看评论
:http://www.cnblogs.com/svitter/