deleting the first and the last character of a string

Markus markus68 at bigfoot.de
Wed Sep 11 21:25:32 CEST 2002


Sean 'Shaleh' Perry wrote:

>> Is there anything which says delete the first or last
>> character of a string? I checked the string module on the web, but I
>> couldn't find anything.
>>
> 
>>>> s = '|f|o|o|'
>>>> s.strip('|')

>>> s[1:-1]
'f|o|o'

-Markus



More information about the Python-list mailing list