现在我使用:
pageHeadSectionFile = open('pagehead.section.htm','r')
output = pageHeadSectionFile.read()
pageHeadSectionFile.close()
Run Code Online (Sandbox Code Playgroud)
但为了使代码看起来更好,我可以这样做:
output = open('pagehead.section.htm','r').read()
Run Code Online (Sandbox Code Playgroud)
使用上述语法时,如何关闭文件以释放系统资源?