vendredi 20 février 2015

extract subsring from string, python

I have a path to some file:



'home/user/directory/filename'


I want get the filename-subpart. The main problem is, I don't know the length of my string and I don't know the length of filename-subpart. I know just that filename is placed at the end of a string after the last slash /. The number of slashes in the string could be absolutely random (because I want get the filename from every directory on some PC). Consequently I don't see for now the usual method with index extraction, like this:



string[number:]


Any ideas?


Aucun commentaire:

Enregistrer un commentaire