File opening and closing in python
File opening and closing in python:
Till now you have learned regarding input and output in a file. Python provides various functions to manipulate files with different operations.
Syntax:
file object = open(file_name [, access_mode][, buffering])
Open function:
In order to deal with the file, you have to open the file using the python ready mate open() function. The open function generally creates the file object which calls others to connect methods.
Supporting parameter details are as follows:
a. file_name:
It is a string value that contains the name or the name of a file that needs to access.
b. access_mode:
Basically, there are three modes: read, write, and append, etc. There is also another optional parameter and default access mode of file i.e. read (r).
c. buffering: Here if the value of buffering is set as 0, therefore no buffering occurs. Line buffering is performing when it accessing a file when the buffering value is 1. When you specify the buffering value greater than 1, then the buffering operation is operated in which the indicated buffer needs size respectively.
