trim start and trailing space chars from string

Tim Williams tim at tdw.net
Sat Sep 15 05:27:36 EDT 2007


On 15/09/2007, 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"?

>>> ' asdf '.strip()
'asdf'
>>> ' asdf '.rstrip()
' asdf'
>>> ' asdf '.lstrip()
'asdf '
>>>



More information about the Python-list mailing list