python中with語句之安全上下文管理

with語句 with open('/tmp/passwd') as f: print(f.read()) 具體實現 class Myopen(object): def __init__(self, name, mode='r'): self.name = name self.mode = mode def __enter__(self):
相關文章
相關標籤/搜索