字符串去除空格的方法

>>> # 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'
>>>

 

posted @ 2018-01-05 09:51  红领巾下的大刀疤  阅读(90)  评论(0)    收藏  举报
/* 看板娘 */