Tuesday, 10 September 2013

python: rstrip one exact string, respecting order

python: rstrip one exact string, respecting order

Is it possible to use the python command rstrip so that it does only
remove one exact string and does not take all letters separately?
I was confused when this happened:
>>>"Boat.txt".rstrip(".txt")
>>>'Boa'
What I expected was:
>>>"Boat.txt".rstrip(".txt")
>>>'Boat'
Can I somehow use rstrip and respect the order, so that I get the second
outcome?

No comments:

Post a Comment