string substitutions

Chris Liechti cliechti at gmx.net
Sat Feb 23 16:41:42 EST 2002


bobnotbob at byu.edu (Bob Roberts) wrote in 
news:c4e6b17d.0202231152.5f87765d at posting.google.com:

> What would be a good way to replace every one or more spaces (" ") 
> in a string with just one space?  Or replace any number of newlines 
> with just one?

>>> ' '.join("h  e    l l   o".split())


-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list