Removing white spaces in Python

Using split()
in = " something     with multiple white spaces   "
parsed = in.split()
output = ' '.join(in)
Using regular expresions
import re
in =  " something     with multiple white spaces   "
output = re.sub("\s+" , " ", in)


Comments

Popular posts from this blog

Como configurar el control de directv para que funcione con el Tv

Como escuchar la rock and pop desde Ubuntu

Adopción de ap unifi cuando el comando set-inform no aparece en el ap por ssh - docker controller