The close() function

This function is used to close the file, which frees the memory acquired by the file. This function is used when the file is not needed anymore or it is going to be opened in a different file mode.

The syntax is as follows:

            Name_of_file_object.close()

The following code syntax can be use to simply open and close a file:

#Opening and closing a file test.txt:
text_file = open("test.txt","a")
text_file.close()
..................Content has been hidden....................

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