How to read an entire line from a text file using Python?

PythonServer Side ProgrammingProgramming

The read function reads the whole file at once. You can use the readlines function to read the file line by line. You can use the following to read the first line:

f = open('my_file.txt', 'r+')
print(f.readline())
raja
Published on 22-Dec-2017 16:11:04
Advertisements