ReferenceString methods
str.startswith()
Whether the string begins with the given text, or any of several.
Signature
text.startswith(prefix)Parameters
| Name | Means |
|---|---|
prefix | a string, or a tuple of strings |
Returns
A bool.
Example
Python
print("report.pdf".startswith("rep"))
print("a.png".startswith(("a", "b")))Output
True True