Reading and Writing Lists to a File in Python
The open(file path, mode) is used to open the required file in the desired mode. The open() method supports various modes of which three are of main concern:
- r: read (default)Python
- w: write
- a: append
write(): Insert the string str1 in a single line in the text file.
read(): used to read data from the file opened using the open() method.
Reading and Writing lists to a file in Python
Reading and writing files is an important functionality in every programming language. Almost every application involves writing and reading operations to and from a file. To enable the reading and writing of files programming languages provide File I/O libraries with inbuilt methods that allow the creation, updation as well and reading of data from the files. Python is no exception. Python too offers inbuilt methods to perform file operations. The io module in Python is used for file handling.
Contact Us