|
Reading From a FilePython provides many different ways to read data from a file. You can:
To read a line of data from a file, use readline:
This function reads a line of data and returns it as a string. The line of data includes the trailing newline character.
The read function reads the entire file into a single string:
The readlines function reads the entire file into a list, with each line of the file contained in an element of the list:
|