源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Python中的lstrip()方法使用简介

  • 时间:2021-08-26 16:33 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Python中的lstrip()方法使用简介
 lstrip()方法返回所有字符被去除开头字符串(缺省为空格字符)的一个复本。 [b]语法[/b] 以下是lstrip()方法的语法:
str.lstrip([chars])

[b]参数[/b] [list] [*]    chars -- 您提供要剪裁的字符。[/*] [/list] [b]返回值[/b] 此方法返回所有字符都被去除字符串开头(缺省为空格字符)的字符串的一个复本。 [b]例子[/b] 下面的例子显示了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

  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部