Python String beginswith() Metode
Voorbeeld
Kyk of die string met "Hallo" begin:
txt = "Hello, welcome to my world."
x = txt.startswith("Hello")
print(x)
Definisie en gebruik
Die startswith()
metode gee True terug as die string met die gespesifiseerde waarde begin, anders Vals.
Sintaksis
string.startswith(value, start, end)
Parameterwaardes
Parameter | Description |
---|---|
value | Required. The value to check if the string starts with |
start | Optional. An Integer specifying at which position to start the search |
end | Optional. An Integer specifying at which position to end the search |
Meer voorbeelde
Voorbeeld
Kyk of posisie 7 tot 20 met die karakters "wel" begin:
txt = "Hello, welcome to my world."
x = txt.startswith("wel",
7, 20)
print(x)