Python with语句
作者:互联网
Python with语句
class A: def __init__(self): print('__init__()') def __enter__(self): print('__enter__()') def __exit__(self, exc_type, exc_val, exc_tb): print('__exit__()') with A() as a: print('run')
结果:
__init__()
__enter__()
run
__exit__()
标签:语句,__,exc,Python,self,init,exit,print 来源: https://www.cnblogs.com/rchang/p/15677899.html