Eleganz way to get rid of \n
gminick at bzt.bzt
Mon Sep 1 15:41:25 CEST 2008
On Mon, 01 Sep 2008 15:25:03 +0200, Hans Müller wrote:
> I'm quite often using this construct:
> for l in open("file", "r"):
> do something
> Has someone a better solution ?
The most general would be to use rstrip() without
>>> a="some string\r\n"
but be careful, because it will also cut whitespaces:
>>> a="some string\t \r\n"
so maybe you could do this:
'some string\t '
More information about the Python-list