1👍
✅
Use os.path.basename(path)
: Returns the base name of pathname path passed as string.
>> os.path.basename('2012/09/08/4f31063d985c97b64e930917b456083c.jpg')
4f31063d985c97b64e930917b456083c.jpg
Read more about it here.
Source:stackexchange.com