PyDocs

Nav

Python Runtime Services

str.removesuffix

builtins

method of str · Added in 3.9
  • str.removesuffix(suffix, /)
Return a str with the given suffix string removed if present.

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.
1 Example
>>> 'MiscTests'.removesuffix('Tests')
'Misc'
>>> 'TmpDirMixin'.removesuffix('Tests')
'TmpDirMixin'
from the Python docs
See Also
No see-alsos for builtins/str.removesuffix
0 Notes
No notes for str.removesuffix