remove whitespace in python
April 17th, 2006 by Lawrence David
assuming you’ve got some string named foo, to remove leading white space:
>>> foo.lstrip()
to remove trailing whitespace:
>>> foo.rstrip()
to remove both lead and trailing whitespace:
>>> foo.strip()
Sweet and simple. Thanks
Nice blog
Thank you!
what about removing spaces in the middle of the string?
import string # or from string import replace
yourstring.replace(‘ ‘,”)
asked google, sent me here, easy answer. ty.
LOL howdoiremovewhitespace.lstrip()
Respected sir
How to remove white spaces which are in middle ?
and:
strip(‘\n’)
to remove “new line” from the end of line
google adwords tool
remove whitespace in python » from the desk of stinkpot