Python 读取文件 with语句 管理上下文时间:2023-03-09 04:09:38 为了避免打开文件后忘记关闭,可以通过管理上下文 with open('file_name', 'r') as f: pass with 执行完毕之后 自动关闭且释放资源