Open this example in the interactive library
Source code
directory, separator, name = 'assets/icons/logo.svg'.rpartition('/')
print(directory, name)Sample output
assets/icons logo.svg

Read the last segment without splitting other separators in Python.
Open this example in the interactive library
directory, separator, name = 'assets/icons/logo.svg'.rpartition('/')
print(directory, name)assets/icons logo.svg