How to get ONLY filename instead of full path?
For example:
path = /folder/file.txt
and i need to get:
filename = file.txt
How to do that?
How to get ONLY filename instead of full path?
For example:
path = /folder/file.txt
and i need to get:
filename = file.txt
How to do that?
You should use the os
module:
import os
filename = os.path.basename(path)
For other path manipulations look here (for python 2.7) or here (for python 3)