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
Updated on 03-Oct-2019 05:44:51

Advertisements