Latest web development tutorials

Python lstrip () method

Python strings Python strings


description

Python lstrip () method is used to cut out spaces or a specified character string on the left.

grammar

lstrip () method syntax:

str.lstrip([chars])

parameter

  • chars - the specified character taken.

return value

Returns a new string resulting amputated left blank or specified character string after.

Examples

The following example shows lstrip () to use:

#!/usr/bin/python

str = "     this is string example....wow!!!     ";
print str.lstrip();
str = "88888888this is string example....wow!!!8888888";
print str.lstrip('8');

Examples of the above output results are as follows:

this is string example....wow!!!
this is string example....wow!!!8888888

Python strings Python strings