re.sub(pattern, repl, string, count=0, flags=0)
import re re.sub(r'\s+', '-', 'hello world')
'hello-world'