How to open a file

broken image
broken image

Python has a built-in open() function to open a file. Hence, in Python, a file operation takes place in the following order: When we are done, it needs to be closed so that the resources that are tied with the file are freed. When we want to read from or write to a file, we need to open it first. Since Random Access Memory (RAM) is volatile (which loses its data when the computer is turned off), we use files for future use of the data by permanently storing them. They are used to permanently store data in a non-volatile memory (e.g. Files are named locations on disk to store related information.

broken image