Python Program to Get the Full Path of the Current Working Directory (Using pathlib module)

bookmark

import pathlib

# path of the given file
print(pathlib.Path("my_file.txt").parent.absolute())

# current working directory
print(pathlib.Path().absolute())

 

Output

/Users/username
/Users/username