perl chomp equivalent in python?
Rich Glazerman
rich.glazerman at synchrologic.com
Wed Feb 9 17:52:13 EST 2000
More information about the Python-list mailing list
Wed Feb 9 17:52:13 EST 2000
- Previous message (by thread): perl chomp equivalent in python?
- Next message (by thread): perl chomp equivalent in python?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Assuming that you know that the line has been read, and the newline is the last character of the line, you can simply do line = line[:-1]. This will chop the last character. Works for any character you're trying to chop... so it's not limited to just the newline, so be careful. Hope this helps. Rich -- Rich Glazerman Test Engineer Synchrologic, Inc. rich.glazerman at synchrologic.com 770-754-5600x176 "a.c.a. serier" <a.serier at hccnet.nl> wrote in message news:87snvk$f2i$1 at news.hccnet.nl... > Hello, > > I have the following problem with lines read with readline. > How to remove the newline at the end? > Perl has chomp() to do this. > In this case use split to split up the line, but the last item has a > newline at the end. > I tried both split and replace(line, '\n', '') without result. > Can't find anything in tutorial, lib ref and FAQ. > > Thank in advance, > > Kees > >
- Previous message (by thread): perl chomp equivalent in python?
- Next message (by thread): perl chomp equivalent in python?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list