Get the directory path of absolute file path in Python
You are looking for this: >>> import os.path >>> fullpath=”/absolute/path/to/file” >>> os.path.dirname(fullpath) ‘/absolute/path/to’ Related functions: >>> os.path.basename(fullpath) ‘file’ >>> os.path.split(fullpath) (‘/absolute/path/to’,’file’)