Home >>Python File Methods >Python File readline() Method
The readline() method in python file is used to read one line from the file. By using the size parameter, you can also return the bytes from the line and kept a trailing newline character in the string.
Syntax:file.readline(size)
Parameter | Description |
---|---|
size | It is Optional. The number of bytes from the line to be read. |
x = open("file1.txt", "r")
print(x.readline())
y = open("file2.txt", "r")
print(y.readline())