Directory and file functions in Python

os module in python provides several methods to work with directories and files. We will look at some of those functions in this lesson

os.chdir() and os.getcwd()

The os.chdir function allows us to change the directory that we’re currently running our Python session in. If you want to actually know what path you are currently in, then you would call os.getcwd(). Let’s try them both out:

Get hands-on with 1200+ tech skills courses.