Baza znanjaIzpitno središče
SLSlovenščina
Izberi jezik13

CKTIS / Python

str.rstrip

Z desne odstrani bele znake ali znake iz neobvezne množice chars.

Različica: Python 3.14; repository image, production runtime not attested

Sintaksa

s.rstrip(chars=None, /)

Z desne odstrani bele znake ali znake iz neobvezne množice chars.

V context.txt odstrani .tx končnico ter nato še t in x imena, zato ostane conte.

Odstranitev točne pripone .txt pusti context.

assert "box.txt".rstrip(".tx") == "bo" and "box.txt".removesuffix(".txt") == "box"

Primeri

print("context.txt".rstrip(".tx"))
print("context.txt".removesuffix(".txt"))

Rezultat

conte
context

Odstranitev točne pripone .txt pusti context.

Viri