Computer Science
Answer
readline() | readlines() |
---|---|
The readline() function reads from a file in read mode and returns the next line in the file or a blank string if there are no more lines. | The readlines() function, also reads from a file in read mode and returns a list of all lines in the file. |
The returned data is of string type. | The returned data is of list type. |
Related Questions
Differentiate between text file and binary file.
Differentiate between write() and writelines().
Write the use and syntax for the following methods:
- open()
- read()
- seek()
- dump()
Write the file mode that will be used for opening the following files. Also, write the Python statements to open the following files:
- a text file “example.txt” in both read and write mode.
- a binary file “bfile.dat” in write mode.
- a text file “try.txt” in append and read mode.
- a binary file “btry.dat” in read only mode.