Some Python 2.1 ideas
Pete Shinners
pshinners at mediaone.net
Sat Dec 23 13:53:22 EST 2000
"Bob Alexander" <bobalex at home.com> wrote
> String method to remove trailing newline
there is a string method named "strip()" that will
remove all whitespace (newline&linefeeds included)
from a string.
actually, since strings are immutable, it returns a
new string with the appropriate changes made.
there are also "rstrip" and "lstrip" functions which
will remove whitespace from only the end or beginning
of the string.
>>> print 'Example string gotten from readline\n'.strip()
'Example string gotten from readline'
More information about the Python-list
mailing list