Geoff Gerrietts geoff at gerrietts.net
Sat Sep 20 01:48:18 CEST 2003

Quoting RR (rr84 at cornell.edu):
> Is there an easy way in python to remove whitespace from a string?

Depending on what you mean by "remove whitespace":

  >>> mystring = " a b c d e f g "
  >>> mystring.strip()
  'a b c d e f g'
  >>> import re
  >>> re.sub("\s+", "", mystring)    

> -- 
> http://mail.python.org/mailman/listinfo/python-list

Geoff Gerrietts             "Whenever people agree with me I always 
<geoff at gerrietts net>     feel I must be wrong." --Oscar Wilde

More information about the Python-list mailing list