-
-
Save owlwang/6be6891207a0a7da1837d256a565bffd to your computer and use it in GitHub Desktop.
This file contains 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
from itertools import islice | |
def next_n_lines(file_opened, N): | |
return [x.strip() for x in islice(file_opened, N)] | |
with open("samplefile", 'r') as f: | |
x = "" | |
while x != []: | |
x = next_n_lines(f, 5) # returns a list | |
pass # do something to x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment