Estoy tratando de eliminar todos los espacios/pestañas/nuevas líneas en Python 2.7 en Linux.Strip espacios/pestañas/líneas nuevas - python
escribí esto, que debe hacer el trabajo:
myString="I want to Remove all white \t spaces, new lines \n and tabs \t"
myString = myString.strip(' \n\t')
print myString
de salida:
I want to Remove all white spaces, new lines
and tabs
Parece como una cosa simple de hacer, sin embargo, yo estoy aquí falta algo. ¿Debería estar importando algo?
No, no debería. –
podría ser útil: http://stackoverflow.com/questions/8928557/python-splitting-string-by-all-space-characters – newtover
Esto funcionó para mí, de la siguiente manera: [Cómo recortar el espacio en blanco (incluidas las pestañas)?] [1] s = s.strip ('\ t \ n \ r') [1]: http://stackoverflow.com/questions/1185524/how-to-trim-whitespace- incluyendo-pestañas – stamat