Python String endswith() Metode
Voorbeeld
Kyk of die string eindig met 'n leesteken (.):
txt = "Hello, welcome to my world."
x = txt.endswith(".")
print(x)
Definisie en gebruik
Die endswith()
metode gee True terug as die string eindig met die gespesifiseerde waarde, anders Vals.
Sintaksis
string.endswith(value, start, end)
Parameterwaardes
Parameter | Description |
---|---|
value | Required. The value to check if the string ends 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 die string eindig met die frase "my wêreld.":
txt = "Hello, welcome to my world."
x = txt.endswith("my world.")
print(x)
Voorbeeld
Kyk of posisie 5 tot 11 eindig met die frase "my wêreld.":
txt = "Hello, welcome to my world."
x = txt.endswith("my world.",
5, 11)
print(x)