perl chomp equivalent in python?
Emile van Sebille
emile at fenx.com
Wed Feb 9 21:16:29 EST 2000
Kees,
Try this:
>>> lines = open(r'c:\config.sys').readlines()
>>> for line in lines:
print line[:-1]
--
Emile van Sebille
emile at fenx.com
-------------------
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
>
>
> --
> http://www.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list