Stripping whitespace from a string. : lstrip « String « Python Tutorial






string1 = "\t  \n  This is a test string. \t\t \n"

print 'Original string: "%s"\n' % string1
print 'Using strip: "%s"\n' % string1.strip()
print 'Using left strip: "%s"\n' % string1.lstrip()
print 'Using right strip: "%s"\n' % string1.rstrip()








5.17.lstrip
5.17.1.Strip tabs
5.17.2.Stripping whitespace from a string.