How you chomp in python

JZ jroznfgre at jngpugbjreXEBCXNbet.cy
Sun Sep 21 06:09:39 EDT 2003


On Fri, 19 Sep 2003 18:43:14 -0700, "Fernando Armenta"
<farmenta at pillardata.com> wrote:

>How you cut off the ^M at the end of a line? rstrip is not working. 

Strings in Perl are mutable so chomp() change the string in place.
Strings in Python are *not* mutable, so rstrip()  does *not* change
the string in place.

>>> s = "abc\n"
>>> s.rstrip()
'abc'
>>> s
'abc\n'
>>> s = s.rstrip()
'abc'

--
JZ




More information about the Python-list mailing list