Mode determines the type of operation (such as reading data from file, writing data from file, closing file )to be done on data file. It tells how the data file will be used after opening it.
|“r”||Read only||Open file in read only mode.|
|“w”||Write only||Existing data of file is truncated and new data is overwritten|
|“a”||Append||Existing data is retained and new data is inserted at the end|
|“r+”||Read and write||Both reading and writing can be done|
|“w+”||Write and read||Both reading and writng cab done Existing data is truncated and new data is added|
|“a+”||Write and read||Both read and write can be done Existing data is retained and new data is inserted at the end.|