Problem with print and output to screen

Mike miguelcoam at gmail.com
Wed Dec 12 01:44:38 CET 2012


El martes, 11 de diciembre de 2012 20:07:09 UTC-3, Joel Goldstick  escribió:
> On Tue, Dec 11, 2012 at 6:00 PM, Dave Angel <d... at davea.name> wrote:
> 
> 
> On 12/11/2012 05:53 PM, Joel Goldstick wrote:
> 
> > When you read the file line by line the end of line character is included
> 
> > in the result
> 
> >
> 
> > try user[:-1] instead to strip the return from your printed text
> 
> >
> 
> 
> 
> The catch to that is the last line in the file might not have a
> 
> newline.  In that case, we'd be ignoring the last character of the line.
> 
> 
> 
> The .rstrip() method is easy, and for most purposes equivalent.  Few
> 
> text files have trailing whitespace, but many are missing the final
> 
> linefeed.
> 
> 
> 
> Point taken.  Brain freeze.  I forgot about .rstrip.  That is the way to go
> 
> 
> 
> --
> 
> 
> 
> DaveA
> 
> 
> 
> 
> 
> 
> -- 
> Joel Goldstick

Thank you very much, i used  "user.rstrip" and the output is correct . 

Best Regards!



More information about the Python-list mailing list