Algorithms and Programming Lab Work 9
File Handling
File handling refers to the management of files in programming. The concept of file handling allows us to open, close, read, write, append, and copy files. Python treats different types of files, whether in binary or text format. To implement file handling in Python, the syntax used is: file = open(‘filename’, ‘mode’).
Python provides three types of modes for opening files:
1 | "r", for Read. |
And don’t forget, once we have finished working with a file, we must call the method to close it. The method to close a file is called using file.close().
MODULE
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments