stripping
Jesse Hager
wrffruntre at tznvy.pbz.ROT13
Tue May 2 15:07:48 EDT 2006
micklee74 at hotmail.com wrote:
> hi
> i have a file test.dat eg
>
> abcdefgh
> ijklmn
> <-----newline
> opqrs
> tuvwxyz
> <---newline
>
>
> I wish to print the contents of the file such that it appears:
> abcdefgh
> ijklmn
> opqrs
> tuvwxyz
>
> here is what i did:
> f = open("test.dat")
> while 1:
> line = f.readline().rstrip("\n")
> if line == '':
> break
> #if not re.findall(r'^$',line):
> print line
>
> but it always give me first 2 lines, ie
> abcdefgh
> ijklmn
>
> What can i do to make it print all..?
> thanks
>
Change the 'break' statement to a 'continue'.
--
Jesse Hager
email = "wrffruntre at tznvy.pbz".decode("rot13")
More information about the Python-list
mailing list