Answers for "python 2 remove spaces from string"

4

remove multiple space python

import re
re.sub(' +', ' ', 'The     quick brown    fox')
'The quick brown fox'
Posted by: Guest on August-05-2020
0

python remove spaces

#If you want to remove LEADING and ENDING spaces, use str.strip():

sentence = ' hello  apple'
sentence.strip()
>>> 'hello  apple'
Posted by: Guest on July-20-2021

Code answers related to "python 2 remove spaces from string"

Python Answers by Framework

Browse Popular Code Answers by Language