Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python lstrip() method

Python lstrip() method

Python Strings Python Strings


Description

The Python lstrip() method removes leading spaces or specified characters from a string.

Syntax

Syntax of the lstrip() method:



str.lstrip([chars])

Parameters

Return Value

Returns a new string generated after removing the leading spaces or specified characters.

Example

The following example shows how to use 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 Strings Python Strings