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

bookmark

import os

# path of the given file
print(os.path.dirname(os.path.abspath("my_file.txt")))

# current working directory
print(os.path.abspath(os.getcwd()))

 

Output

/Users/username
/Users/username