Read file line by line in python
Python program to read a file line by line
Program or Solution
file=open("sample.txt",'r')
content = file.readline()
while(content):
print(content)
content=file.readline()
file.close()
Program Explanation
open the file in read mode read line by line using readline() method.
Read a line and check whether there is content in the line, then print it and read the next line.
Repeat it until a line has no content.
close() the file.
Comments
coming Soon
coming Soon