Last active
September 25, 2020 14:33
-
-
Save EdoardoVignati/31d84b33f1e7e73457088649462e441a to your computer and use it in GitHub Desktop.
Read a file per line with python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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