pythonbook/10个编程技巧/with 语句.py

5 lines
104 B
Python

#自动关闭文件
with open('mytest.txt') as file_in:
for line in file_in:
print(line)