什么 时候可以用with操作

# 什么时候with操作   对象里面实现enter或者exit操作 就可以用with
class WithObject(object):
    
    def __enter__(self):
        pass
    def __exit__(self, exc_type, exc_val, exc_tb):
        pass

猜你喜欢

转载自blog.csdn.net/weixin_42785547/article/details/85049650