删除左右两边空格
Whitespace stripping
s = ' hello world \n'
s.strip()
'hello world'
s.lstrip()
'hello world \n'
s.rstrip()
' hello world'
删除字符
Character stripping
t = '-----hello====='
t.lstrip('-')
'hello====='
t.strip('-=')
'hello'
删除中间空格
s.replace(' ', '')
'helloworld'
import re
re.sub('\s+', ' ', s)
'hello world'