#-*-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/else/finally语句
- Python中异常处理简单示例(try,except,finally)
- Python异常处理try...except...finally raise assert
- [代码笔记] python之 异常处理 try except else finally
- Python异常处理try...except...finally raise assert
- python异常处理--try except else raise finally
- vc++6中的结构化异常处理try-except-finally语句
- Python中的错误和异常处理简单操作示例【try-except用法】
- Python中的异常处理try/except/finally/raise用法分析
- 简单介绍Python中的try和finally和with方法