字符串 lstrip() 方法用于返回去除字符串左边的空格或指定字符后的新字符串。

语法:

字符串.lstrip([char])

参数说明:

char:可选参数,指定去除左边的字符。

返回值:

返回去除左边空格或指定字符后的新字符串。

示例:

str = "   hello, world!   "
print(str.lstrip())   # 输出:'hello, world!   '
print(str.lstrip(' h'))   # 输出:', world!   '
Python 字符串 lstrip 方法

原文地址: https://www.cveoy.top/t/topic/dCIo 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录