Computer Science
How are open() functions different from close() functions other than their functionality of opening and closing files?
Python Data Handling
1 Like
Answer
| open() functions | close() functions |
|---|---|
| It creates a file object, which allows to perform various operations on the file, such as reading from it, writing to it, or appending data to it. | When we're done working with a file, we should always close it using the close() function to free up system resources and prevent data loss. |
The syntax is : file_objectname = open("filename", "mode") | The syntax is : file.close() |
Answered By
2 Likes
Related Questions
What is the difference between "w" and "a" modes ?
What is the significance of a file-object ?
Write statements to open a binary file 'C:\Myfiles\text1.dat' in read and write mode by specifying the file path in two different formats.
In which of the following file modes, the existing data of file will not be lost ?
- 'rb'
- ab
- w
- w + b
- 'a + b'
- wb
- wb+
- w+
- r+