[Tutor] deleting CR within files

David Talaga dtalaga at novodynamics.com
Mon Apr 19 08:29:09 EDT 2004


Ok, so now I am extremely close!
It is now deleting al of the character returns instead of leaving just one.
I tried to put an argument in there but as it is defined there can only be a
string in write.  I am not to sure where to go next.  I am playing around
with the other string manipulation options but don't know where to add that
I need to keep 1 <cr>

David Talaga

-----Original Message-----
From: Alan Gauld [mailto:alan.gauld at blueyonder.co.uk]
Sent: Saturday, April 17, 2004 3:47 PM
To: David Talaga; Roger Merchberger; tutor at python.org
Subject: Re: [Tutor] deleting CR within files


> for i in in_file:
>       out_file.write(i[:])
>
> This does what I need with the excpetion that it dosent do it for
every
> line.  It is currous because it will take off a <cr> from one line
and not
> the next 2 and then from another line...  currious...

Are you sure thats not the origoinal data?

Try using the strip function since it will only strip off if there
is anything to strip so should work in all cases.

ie.   out_file.write(i.strip())

HTH,

Alan G





More information about the Tutor mailing list