上下文管理器 上下文管理器 打开文件 执行完with语句后 自动关闭该文件 f = open('/tmp/passwd') with open('/tmp/passwd') as f: print(f.read()) print(f.closed)