Skip to navigation
Split a string by the last character occurrence
14.03.18
s = '1/2/3/4/5/6/7' a = s.rsplit('/',1) print(a) >> ['1/2/3/4/5/6', '7'] str.rsplit([sep[, maxsplit]]) Return a list of the words in the string, using sep as the delimiter string. If maxsplit is given, at most maxsplit splits are done, the rightmost ones. If sep is not specified or None, any whitespace string is a separator. Except for splitting from the right, rsplit() behaves like split() which is described in detail below. New in version 2.4.
https://docs.python.org/2/library/stdtypes.html#str.rsplit
Reply
Anonymous
Information Epoch 1714559397
Files are bags of bytes.
Home
Notebook
Contact us