Chopping off spaces at both ends
Bengt Richter
bokr at oz.net
Sun Aug 7 18:25:34 EDT 2005
On 7 Aug 2005 10:14:33 -0700, "Kay Schluehr" <kay.schluehr at gmx.net> wrote:
>Use the strip() method.
>
>Example:
>
>>>> "\t abc \n".strip()
>"abc"
>
>Variants are lstrip() and rstrip().
>
and also occasionally useful:
>>> 'abc123cab'.strip('bca')
'123'
I.e., a strip argument as an unordered set of characters that
causes stripping so long as characters at the end(s) of the
string being stripped are found that are in the set.
Regards,
Bengt Richter
More information about the Python-list
mailing list