How to get only the last part of a path in Python?
How to get only the last part of a path in Python? Question: In python, suppose I have a path like this: /folderA/folderB/folderC/folderD/ How can I get just the folderD part? Asked By: pepero || Source Answers: You could do >>> import os >>> os.path.basename(‘/folderA/folderB/folderC/folderD’) UPDATE1: This approach works in case you give it /folderA/folderB/folderC/folderD/xx.py. …
Total answers: 10