python 字符串技巧

str.lstrip([chars])

参数:

  • chars 字符用来选择被删除的元素,默认为空格

返回值:

  • 删除前面元素后的新字符串

例子:

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

输出:

1
2
his is string example....wow!!!
this is string example....wow!!!8888888

0%