I have a string that contains a path
str = \"/example/path/with/different/trailing/delimiter\\\"
and I want to trim the leading and traili
Example of strip()
in action; in this case, removing a leading plus sign:
In [1]: phone_number = "+14158889999"
In [2]: phone_number.strip('+')
Out[2]: '14158889999'
I believe strip is the pythonic way. It is usually the case when there is a builtin function.
There are a few builtin path manipulators available in the os library. You might want to use them if one of the manipulators is a match for your use case.