home ~ socials ~ projects ~ rss

Read A File Line By Line In Python

October 2021

You can just use the file handle with a for loop.

for file in source_files:
    with open(file) as _file:
        for line if _file:
            print(line)
end of line
Share link:
https://www.alanwsmith.com/en/20/eo/bx/fu/?read-a-file-line-by-line-in-python