I'm trying to understand what string.strip() in python is doing:
In [35]: t1 = '-MIN-North'
In [36]: t1.strip('-MIN-')
Out[36]: 'orth'
In [37]: t2 = '-MIN-north'
In [38]: t2.strip('-MIN-')
Out[38]: 'north'
Why is t1.strip('-MIN-')
not equal to 'North'
but t2.strip('-MIN-')
equal to 'north'
?
strip
is taking out all the characters you provide it in the argument.
In your first example, it is stripping out the N
from North
because N
is in -MIN-
.
In the second, it is not stripping the n
from north
because n
is not in -MIN-
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With