deleting the first and the last character of a string
Sean 'Shaleh' Perry
shalehperry at attbi.com
Wed Sep 11 10:56:21 EDT 2002
On Wednesday 11 September 2002 03:58, Manuel Hendel wrote:
> I got a file with fields seperated by a "|". The problem is that there
> is also a "|" at the beginning and at the end of each line although
> there no fields in front or behind these "|". Now I want to delete
> these two "|". 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('|')
'f|o|o'
and of course the equivalent strip call from the string module.
More information about the Python-list
mailing list