Home >>Python File Methods >Python File readlines() Method
The readlines() method in python file is used to returns the list containing each line in the file. Generally, no more lines are returned, if the total number of bytes returned will exceed the specified number.
Syntax:file.readlines(hint)
Parameter | Description |
---|---|
hint | This parameter is used the Number of lines to be read from the file. -1 is a default value, refers to all lines will be returned. |
x = open("file1.txt", "r")
print(x.readlines())
y = open("file2.txt", "r")
print(y.readlines())