KnowledgeBoat Logo
LoginJOIN NOW

Computer Science

How is file open() function different from close() function?

Python File Handling

16 Likes

Answer

open() functionclose() function
The open() function is used to open a file.The close() function is used to close a file object.
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

10 Likes


Related Questions