ID EN
Built-in Types

removesuffix

Python 3.11

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:

Syntax

PYTHON
str.removesuffix(suffix, /)

Examples

Example 1
PYTHON
>>> 'MiscTests'.removesuffix('Tests')
'Misc'
>>> 'TmpDirMixin'.removesuffix('Tests')
'TmpDirMixin'