trim start and trailing space chars from string

Rustom Mody rustompmody at gmail.com
Sat Sep 15 13:02:48 CEST 2007


>>> s="     abcdef     "
>>> s.strip()
'abcdef'
>>> s.rstrip()
'     abcdef'
>>> s.lstrip()
'abcdef     '
>>>


On 9/15/07, Konstantinos Pachopoulos <kostaspaxos at yahoo.gr> wrote:
> Hi,
> is there something corresponding to the java String.trim() method, ie
> trim start and trailing space/tab chars from string?
> say convert " asdf   "  to "asdf"?
>
> Thnx
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list