我想在Linux上的Python 2.7中删除所有空格/制表符/换行符。带空格/制表符/换行符 - python
我写了这个,是应该做的工作:
myString="I want to Remove all white \t spaces, new lines \n and tabs \t"
myString = myString.strip(' \n\t')
print myString
输出:
I want to Remove all white spaces, new lines
and tabs
这似乎是一个简单的事情,但我在这里失去了一些东西。我应该输入什么东西?
没有它不应该。 –
可能是有用的:http://stackoverflow.com/questions/8928557/python-splitting-string-by-all-space-characters – newtover
这对我来说,从:[如何修剪空白(包括标签)?] [1] S = s.strip( '\吨\ n \ R') [1]:http://stackoverflow.com/questions/1185524/how-to-trim-whitespace-包括标签 – stamat