I've encountered this now and I can't understand what's going on here...:
"a//abc".lstrip("a:/")
# "bc"
Another example:
"a//bcd".lstrip("a:/")
# "bcd"
Does ":" perhaps have a special meaning for the stripping functions?
I've encountered this now and I can't understand what's going on here...:
"a//abc".lstrip("a:/")
# "bc"
Another example:
"a//bcd".lstrip("a:/")
# "bcd"
Does ":" perhaps have a special meaning for the stripping functions?
Because lstrip
removes all characters of a set, not a substring
If you want to remove a substring from the start of a string only, I usually do:
# data = "a//abc"
# subs = "a:/"
if data.startswith(subs):
data = data[len(subs):]