First page Back Continue Last page Overview Graphics
Stripping Strings
- s.strip([chars])
Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped
- s.lstrip([chars])
like strip(), but only from left side.
- s.rstrip([chars])
like strip() but from right side.
Sometimes strings have trailing or leading characters which have to be removed. In most cases whitespaces.