mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
[3.13] gh-106318: Add example for str.endswith()
(GH-134523) (#135460)
gh-106318: Add example for `str.endswith()` (GH-134523)
(cherry picked from commit eed827ed09
)
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
db408a484c
commit
c260ed15d1
1 changed files with 13 additions and 1 deletions
|
@ -1727,7 +1727,19 @@ expression support in the :mod:`re` module).
|
|||
Return ``True`` if the string ends with the specified *suffix*, otherwise return
|
||||
``False``. *suffix* can also be a tuple of suffixes to look for. With optional
|
||||
*start*, test beginning at that position. With optional *end*, stop comparing
|
||||
at that position.
|
||||
at that position. Using *start* and *end* is equivalent to
|
||||
``str[start:end].endswith(suffix)``. For example::
|
||||
|
||||
>>> 'Python'.endswith('on')
|
||||
True
|
||||
>>> 'a tuple of suffixes'.endswith(('at', 'in'))
|
||||
False
|
||||
>>> 'a tuple of suffixes'.endswith(('at', 'es'))
|
||||
True
|
||||
>>> 'Python is amazing'.endswith('is', 0, 9)
|
||||
True
|
||||
|
||||
See also :meth:`startswith` and :meth:`removesuffix`.
|
||||
|
||||
|
||||
.. method:: str.expandtabs(tabsize=8)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue