Python 简单异常处理
2014-05-02 23:28
483 查看
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...")
相关文章推荐
- python 常见面试问题(1)-python 输出中文问题/求list的交集或差集/一个简单的socket编程/python 异常处理
- python错误和异常处理的简单操作实例(try-except)
- Python中的错误和异常处理简单操作示例【try-except用法】
- python错误和异常处理的简单操作实例(try-except)
- python 之装饰器执行过程简单解析
- 用python创建一个简单的restful风格的web服务应用
- 用Python学《微积分B》(有理式与简单无理式积分套路)
- Java简单入门【对比Python】Part2.POST JOSN请求
- Python 实现简单的稀疏矩阵
- python机器学习——KNN算法简单入门(真的很简单!)
- 最简单的服务器和客户机(python3的编码与解码问题)
- python连接mysql简单小程序
- Python 爬虫(1)基础知识和简单爬虫
- 用python来解析xml文件(简单情况)
- windows下一个简单的输入法模块[Python]
- python nltk库的安装和简单使用
- Python 写一个简单的FTPv2
- python3.X安装matplotlib简单方法
- python lambda匿名函数简单理解
- Python3简单教程(四)迭代器与生成器