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

Fredrik Lundh fredrik at pythonware.com
Tue Dec 13 07:50:44 EST 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