Closing files

When we've finished writing, we should remember to close the file by calling the close() method:

>>> f.close()

Note that it's only after we close the file that we can be certain that the data we've written becomes visible to external processes. Closing files is important!

Also remember that you can no longer read from or write to a file after closing it. Attempts to do so will result in an exception.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset