rodrigosantosbr

[Python] Remove/strip all whitespaces from a string

Feb 14th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.10 KB | None | 0 0
  1. import re
  2.  
  3. string1 = 'strip my spaces'
  4. out = re.sub(r'\s+', '', string1) #stripmyspaces
  5. print(out)
Advertisement
Add Comment
Please, Sign In to add comment