PyDocs

Nav

Python Runtime Services

bytes.removesuffix

builtins

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

If the bytes ends with the suffix string and that suffix is not
empty, return bytes[:-len(prefix)].  Otherwise, return a copy of the
original bytes.
1 Example
>>> b'MiscTests'.removesuffix(b'Tests')
b'Misc'
>>> b'TmpDirMixin'.removesuffix(b'Tests')
b'TmpDirMixin'
from the Python docs
See Also
No see-alsos for builtins/bytes.removesuffix
0 Notes
No notes for bytes.removesuffix