Contribute Media
A thank you to everyone who makes this possible: Read More

Read a file line-by-line in Python


When Python reads a file line-by-line, it doesn't store the whole file in memory all at once. Files are lazy iterables, and as we loop over a file object, we'll get lines from that file.


Improve this page