How you chomp in python
Gary Herron
gherron at islandtraining.com
Fri Sep 19 21:59:36 EDT 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