strip

Strip removes beginning and ending whitespace characters (spaces, tabs, and line breaks), useful for reading lines of a textfile.

extracting text without surrounding spaces

>>> ' enclosed text '.strip()

'enclosed text'

define own characters to get removed

>>> ',A,B,C,,,,,'.strip(',')

'A,B,C'

remove only from one side: left (lstrip) or right (rstrip)

>>> '0001230'.lstrip('0')

'1230'

for removing prefix or suffix, better using 'replace'

>>> 'www.example.com'.replace('www.','')

'example.com'

https://docs.python.org/3.5/library/stdtypes.html?highlight=strip#str.strip