非正常研究-----python with 语句研究
2011-08-04 09:41
609 查看
import sys class test: def __enter__(self): print "enter" return 1 def __exit__(self,*args): print "exit" return True with test() as t: print "t is not the result of test().it is __enter__ returned" print "t is 1,yes,it is {0}".format(t) #raise NameError("hi here") #sys.exit() print "Never here"
相关文章推荐
- python with 语句研究
- 理解Python的With语句
- 浅谈 Python 的 with 语句
- 说一说那些我也不太懂的 python with 语句
- python中with语句的用法
- Python 的 with 语句
- python __enter__ 与 __exit__的作用,以及与 with 语句的关系
- Python之with语句原理
- 理解python的with语句
- 理解Python的With语句
- Python with语句及context manager
- python3 else语句和with语句
- Python笔记:浅谈with语句
- python学习笔记:利用contextlib和@contextmanager实现with语句上下文实例
- python with语句
- 浅谈 Python 的 with 语句
- 浅谈 Python 的 with 语句
- 理解Python的With语句
- Python中with语句的理解
- 浅谈 Python 的 with 语句