python remove consecutive spaces

38

# credit to the Stack Overflow user in the source link

import re
re.sub(' +', ' ', 'The     quick brown    fox')
>>> 'The quick brown fox'

Comments

Submit
0 Comments