在Python中想要使用with的建议做法是使用@contextmanager装饰器,由python提供但需要导入
@contextmanager
def fun(args):
pass
yeild result
with fun(args) as f:
pass在Python中想要使用with的建议做法是使用@contextmanager装饰器,由python提供但需要导入
@contextmanager
def fun(args):
pass
yeild result
with fun(args) as f:
pass