How do i read line from an input file, without the /n

Fredrik Lundh fredrik at pythonware.com
Tue Dec 13 13:50:44 CET 2005


"doritrieur" <doritrieur at hotmail.com> wrote:

> How do i read line from an input file, without the /n ?
> the readline function returns also the /n character at the end. i need
> to read a line without the training /n

so strip if off!

line = line[:-1] # remove last char

see also:

http://www.python.org/doc/faq/programming.html#is-there-an-equivalent-to-perl-s-chomp-for-removing-trailing-newlines-from-strings

</F> 






More information about the Python-list mailing list