Python 字符串方法
删除字符串左侧的空格:
txt = " banana " x = txt.lstrip() print("of all fruits", x, "is my favorite")
运行实例
lstrip() 方法删除所有前导字符(空格是要删除的默认前导字符)。
string.lstrip(characters)
删除前导字符:
txt = ",,,,,ssaaww.....banana" x = txt.lstrip(",.asw") print(x)