Definition
The readlines() method returns a list containing each line in the file as a list item.
Using the hint parameter limits the number of lines returned. If the total number of bytes returned exceeds the specified number, no more lines are returned.
Syntax
file.readlines(hint)
Parameters
Parameter | Description |
---|---|
hint | Optional. If the number of bytes returned exceed the hint number, no more lines will be returned. Default value is -1, which means all lines will be returned. |
Examples:
f = open("myFile.txt", "r")
print(f.readlines())
f = open("myFile.txt", "r")
print(f.readlines(36))