open
1, open the file
file = open ( "filename", "read-write mode")
2, manipulate files
***
3, close the file
file.close()
Precautions :
Using the open method, the file must be closed after the operation is completed, or long-term stay connected to the file, causing memory overflow occurred.
with open
1, open the file
with open ( "filename", "read-write") as file:
2, manipulate files
***
3, close the file (automatically turn off)