start reading from certain line

jstrick jstrick at mindspring.com
Thu Jul 10 09:45:47 EDT 2008


Here's a simple way to do it with a minimum amount of loopiness (don't
forget to use 'try-except' or 'with' in real life):

f = open("item1.txt")

for preline in f:
    if "Item 1" in preline:
        print preline,
        for goodline in f:
            # could put an end condition with a 'break' here
            print goodline,

f.close()



More information about the Python-list mailing list