Python lstrip() Method

Python 字符串Python String


Description

The Python lstrip() method is used to strip whitespace or specified characters from the left side of a string.

Syntax

lstrip() method syntax:

str.lstrip([chars])

Parameters

  • chars -- The characters to be stripped.

Return Value

Returns a new string generated by stripping the whitespace or specified characters from the left side of the string.

Example

The following example demonstrates the usage of lstrip():

#!/usr/bin/python

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

The output of the above example is:

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

Python 字符串Python String

Other Extensions