PyDocs

Nav

Python Runtime Services

str.removeprefix

builtins

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

If the string starts with the prefix string, return
string[len(prefix):].  Otherwise, return a copy of the original
string.
1 Example
>>> 'TestHook'.removeprefix('Test')
'Hook'
>>> 'BaseTestCase'.removeprefix('Test')
'BaseTestCase'
from the Python docs
See Also
No see-alsos for builtins/str.removeprefix
0 Notes
No notes for str.removeprefix