contextmanager 的基本使用

from contextlib import contextmanager

简化 With 语句:

 
 

灵活使用@contextmanager:

 
 

该代码的意义是: 在某个事件, 或者某段代码执行前与执行后, 分别执行什么

 

猜你喜欢

转载自www.cnblogs.com/amou/p/9509163.html