Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,9 @@ expression support in the :mod:`re` module).

If the string starts with the *prefix* string, return
``string[len(prefix):]``. Otherwise, return a copy of the original
string::
string:

.. doctest::

>>> 'TestHook'.removeprefix('Test')
'Hook'
Expand All @@ -2240,12 +2242,16 @@ expression support in the :mod:`re` module).

.. versionadded:: 3.9

See also :meth:`removesuffix` and :meth:`startswith`.


.. method:: str.removesuffix(suffix, /)

If the string ends with the *suffix* string and that *suffix* is not empty,
return ``string[:-len(suffix)]``. Otherwise, return a copy of the
original string::
original string:

.. doctest::

>>> 'MiscTests'.removesuffix('Tests')
'Misc'
Expand All @@ -2254,6 +2260,8 @@ expression support in the :mod:`re` module).

.. versionadded:: 3.9

See also :meth:`removeprefix` and :meth:`endswith`.


.. method:: str.replace(old, new, /, count=-1)

Expand Down
Loading