6 ответов
+ 2
You might be using the with statement?
With the with statement you should know that the file will be automatically closed in the end.
with open(filename) as f:
#f would be opened here.
#f would be closed here.
Was that the problem?
+ 2
One of the main advantages of using with is that it will automatically close the file, even though there were errors.
0
Mirielle🐶 [Inactive] I don't know about those unexpected closes, but confusion about with statement sounded a more likely reason.
0
For closing python code ,there is a one best process that is 'exit()'