目录

lstrip()

描述 (Description)

方法lstrip()返回字符串的副本,其中所有字符都已从字符串的开头删除(默认空格字符)。

语法 (Syntax)

以下是lstrip()方法的语法 -

str.lstrip([chars])

参数 (Parameters)

  • chars - 你可以提供必须修剪的字符。

返回值 (Return Value)

此方法返回字符串的副本,其中所有字符都已从字符串的开头删除(默认空白字符)。

例子 (Example)

以下示例显示了lstrip()方法的用法。

#!/usr/bin/python
str = "     this is string example....wow!!!     ";
print str.lstrip()
str = "88888888this is string example....wow!!!8888888";
print str.lstrip('8')

当我们运行上面的程序时,它产生以下结果 -

this is string example....wow!!!
this is string example....wow!!!8888888
↑回到顶部↑
WIKI教程 @2018