Python中异常处理简单示例(try,except,finally)
2015-05-04 21:27
811 查看
#-*-coding:utf-8-*- import sys def Main(): try: f=open('firstpython.py') s=f.readline() print s except IOError,(errno,strerror): print "I/O error(%s):%s" %(errno,strerror) except ValueError: print "could not convert data to an integer" except: print "Unexpected error:",sys.exc_info()[0] raise finally: f.close() if __name__=="__main__": Main()
相关文章推荐
- Python异常处理try...except...finally raise assert
- python try...except....else...finally处理异常
- Python学习笔记之错误处理(关键词:错误处理、异常机制、try、except、else、finally、raise)
- python异常处理try,except,else,finally,raise
- Python3基础 try-except-finally 的简单示例
- python异常处理try,except,else,finally,raise
- Python异常处理try...except...finally raise assert
- Python中的异常处理: try-except-else-finally
- python中的异常处理:try...except...else...finally语句
- python 异常处理-try-except-else-finally
- python 异常错误 try except else finally
- Python 异常处理 try/except
- Python 异常处理 Python 基础教程 try..except
- python 对异常的处理(try...finally...和with 方法)- 千月的python linux 系统管理指南学习笔记(15)
- Python异常处理try...except、raise
- Python异常捕捉try except else finally有return时执行顺序探究
- 【】Python】异常处理try...except、raise
- python try except, 异常处理
- Python---异常处理try...except、raise
- Python 异常处理 (try 和 except)