Les espaces de coupe dans String Python
a = " yo! "
b = a.strip() # this will remove the white spaces that are leading and trailing
Super Stoat
a = " yo! "
b = a.strip() # this will remove the white spaces that are leading and trailing
import re
s = '\n \t this is a string with a lot of whitespace\t'
s = re.sub('\s+', '', s)
sentence = ' hello apple'
sentence.strip()
>>> 'hello apple'
>>> import re
>>> re.sub(' +', ' ', 'The quick brown fox')
'The quick brown fox'
' hello world! '.strip()
'hello world!'
' hello world! '.lstrip()
'hello world! '
' hello world! '.rstrip()
' hello world!'
' sss d ssd s'.replace(" ", "")
# output: 'sssdssds'