Methode Python String lstrip()
Voorbeeld
Verwijder spaties links van de tekenreeks:
txt = " banana "
x =
txt.lstrip()
print("of all fruits", x, "is my favorite")
Definitie en gebruik
De lstrip()
methode verwijdert alle voorlooptekens (spatie is het standaard voorloopteken dat moet worden verwijderd)
Syntaxis
string.lstrip(characters)
Parameterwaarden
Parameter | Description |
---|---|
characters | Optional. A set of characters to remove as leading characters |
Meer voorbeelden
Voorbeeld
Verwijder de hoofdletters:
txt = ",,,,,ssaaww.....banana"
x = txt.lstrip(",.asw")
print(x)