How to process a file line by line in Python?

In Python, how to process read a file line by line to process it?

Like those lines in Bash:

while read line ; do
    echo $line
done < ./input.txt
related to an answer for: How to process a file line by line in Go?
asked Mar 17 by anonymous

1 Answer

In Python, you can process a file line by line by a for in the file like

with open("./input.txt", "r") as thefile:
  for line in thefile:
    print line
answered Mar 30 by timyang (140 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...