Skip to content

Instantly share code, notes, and snippets.

@EdoardoVignati
Last active September 25, 2020 14:33
Show Gist options
  • Save EdoardoVignati/31d84b33f1e7e73457088649462e441a to your computer and use it in GitHub Desktop.
Save EdoardoVignati/31d84b33f1e7e73457088649462e441a to your computer and use it in GitHub Desktop.
Read a file per line with python
#!/usr/bin/env python
filepath = 'file.txt'
with open(filepath) as fp:
line = fp.readline()
while line:
print(line.strip())
line = fp.readline()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment