How you chomp in python

Gary Herron gherron at islandtraining.com
Sat Sep 20 03:59:36 CEST 2003


On Friday 19 September 2003 06:43 pm, Fernando Armenta wrote:
> How you cut off the ^M at the end of a line? rstrip is not working.
>
>
>
> string.rstrip(build_number)
>
>
>
> thanks,
>
>
>
> -F

It works for me.  What is your evidence that it is not working?

>>> s = 'abc\n\r' # Has a ^M as last character
>>> print len(s)
5
>>> print len(string.rstrip(s)) # This works, 
3
>>> print len(s.rstrip())  # but this is preferred
3
>>>


Gary Herron







More information about the Python-list mailing list