I think this question is more of a "coding style" rather than technical issue.
Said I have a line of code:
buf = open('test.txt','r').readlines()
...
Will the file descriptor automatically close, or will it stay in the memory?
If the file descriptor is not closed, what is the prefer way to close it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…