Strings do have few methods to do striping. The simplest one is
strip(chars). If you provide the chars argument then it will strip any combination of them. By default it strips only whitespace or newline characters.
>>> s = " abc\n "
>>> s.strip()
'abc'
You can particularly strip from the left hand or right hand side also using
lstrip(chars) or
rstrip(chars).
>>> s = "www.foss.in"
>>> s.lstrip("cwsd.")
'foss.in'
>>> s.rstrip("cnwdi.")
'www.foss'