>>> import os
>>> pth="/abeja/blanca/zumbas/ebria/de/miel/en/mi/alma/y.te.tuerces"
>>> os.path.split(os.path.dirname(pth))[1]
'alma'
>>>
Mostly Linux & Python syntax notes and hyperlinks.
Subscribe to:
Post Comments (Atom)
Mostly Linux & Python syntax notes and hyperlinks.
You da' woman! Thank you!
ReplyDeleteI was searching for this solution in a lot of websites and wasted almost a couple of hours for this one line.
ReplyDeleteThanks a TON !! Keep the good work going ...
I'm so glad it helped.
DeleteI love you!
ReplyDeleteYou can use Long Path Tool, it works for such problems..
ReplyDeleteThanks, do you have a link for that?
DeleteThank You, exactly what I was looking for.
ReplyDelete