How to go up one directory in Python

Moving up one directory allows us to navigate to a current working directory one level up.

Solution for How to go up one directory in Python : You can use os.path.dirname to go up one directory Call os.getcwd() to get the current working directory. Call os.path.dirname(path) to go a folder up from path. Use os.chdir(path) to move to this new directory.


how-to-go-up-one-directory-in-python