CKTIS / Python
str.removesuffix
Rimuove una volta il suffisso esatto.
Versione: Python 3.14; repository image, production runtime not attested
Sintassi
s.removesuffix(suffix)Rimuove una volta il suffisso esatto.
Con .tar, a.tar.tar diventa a.tar, mentre un suffisso vuoto conserva tutto il testo.
Una fetta fino a −0 termina prima della posizione zero e sarebbe vuota.
assert "abc".removesuffix("") == "abc" and "abc"[:-0] == ""
Esempi
print("a.tar.tar".removesuffix(".tar"))
print("a.tar".removesuffix(""))
Risultato
a.tar a.tar
Una fetta fino a −0 termina prima della posizione zero e sarebbe vuota.