Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc260ed1

Browse files
miss-islingtonblaisephugovk
authored
[3.13]gh-106318: Add example forstr.endswith() (GH-134523) (#135460)
gh-106318: Add example for `str.endswith()` (GH-134523)(cherry picked from commiteed827e)Co-authored-by: Blaise Pabon <blaise@gmail.com>Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parentdb408a4 commitc260ed1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

‎Doc/library/stdtypes.rst‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,19 @@ expression support in the :mod:`re` module).
17271727
Return ``True`` if the string ends with the specified *suffix*, otherwise return
17281728
``False``. *suffix* can also be a tuple of suffixes to look for. With optional
17291729
*start*, test beginning at that position. With optional *end*, stop comparing
1730-
at that position.
1730+
at that position. Using *start* and *end* is equivalent to
1731+
``str[start:end].endswith(suffix)``. For example::
1732+
1733+
>>> 'Python'.endswith('on')
1734+
True
1735+
>>> 'a tuple of suffixes'.endswith(('at', 'in'))
1736+
False
1737+
>>> 'a tuple of suffixes'.endswith(('at', 'es'))
1738+
True
1739+
>>> 'Python is amazing'.endswith('is', 0, 9)
1740+
True
1741+
1742+
See also:meth:`startswith` and:meth:`removesuffix`.
17311743

17321744

17331745
..method::str.expandtabs(tabsize=8)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp