how to start reading at line X in python? -


actually read file this:

f = open("myfile.txt") line in f:     #do s.th. line 

what need start reading not @ first line, @ x line? (e.g. 5.)

an opened file object f iterator. read (and throw away) first 4 lines , go on regular reading:

with open("myfile.txt", 'r') f:     in xrange(4):         next(f, none)     line in f:         #do s.th. line 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -