How can I get the path of a file without the file basename ?
Something like /a/path/to/my/file.txt --> /a/path/to/my/
/a/path/to/my/file.txt
/a/path/to/my/
Tried with .split
You can import os
import os
>>> filepath '/a/path/to/my/file.txt' >>> os.path.dirname(filepath) '/a/path/to/my' >>>
Use os.path.dirname(filename).
os.path.dirname(filename)
(dirname, filename) = os.path.split(path)
Check subs of os.path
os.path
os.path.dirname('/test/one')