*预定义清理:with
上一节
下一节
with open("myfile.txt") as f:
for line in f:
print(line, end="")
以上这段代码执行时,即使出问题了,文件 f 总是会关闭。
目录
with open("myfile.txt") as f:
for line in f:
print(line, end="")
以上这段代码执行时,即使出问题了,文件 f 总是会关闭。