To remove some lines from a file

umut.tabak at student.kuleuven.be umut.tabak at student.kuleuven.be
Wed Oct 25 15:39:43 CEST 2006


Thanks, I have learnt sth from the library BTW.

Regards
On Oct 25, 3:32 pm, "Jerry" <jwe... at gmail.com> wrote:
> Very inelegant, but you get the idea:
>
> counter = 0
>
> f = open("test.txt")
> for line in f.readlines():
>     if line[0] != "$" and counter < 2:
>         counter += 1
>         continue
>     else:
>         print line,
> 
> --
> Jerry




More information about the Python-list mailing list