代码示例:(标识:python_ref_file_close)
python_ref_file_close.py
f = open("demofile.txt", "r")

print(f.read())

f.close()
运行结果: