在Python中,lstrip()函数可以用于去除字符串开头的指定字符或字符序列。它的使用方法如下:
去除开头的空格:str1 = " hello world"result = str1.lstrip()print(result) # 输出:hello world去除开头的指定字符或字符序列:str2 = "###hello world"result = str2.lstrip("#")print(result) # 输出:hello worldstr3 = "abcabcabc123"result = str3.lstrip("abc")print(result) # 输出:123注意:lstrip()函数只能去除字符串开头的字符,并不会对字符串中间或结尾的字符进行操作。

