I'm aware that I can do either of the two to get the full path to a file:
>>> import os
>>> import pathlib
>>> path1 = str(pathlib.Path('filename').parent.absolute())
>>> path2 = os.path.abspath('filename')
The current structure of the absolute path to filename
is /home/user/directory/filename
. However, when I print the two variables path1
and path2
I only get /home/user/filename
with the directory
omitted.
Would anybody know why this happens, and how I can fix it? Thanks.