In this article we will discuss how to get the current working directory in Python.

Python’s os module provides a function to get the current working directory i.e.

It returns a string containing the current working directory.

For calling this function we need to import os module i.e.

Let’s understand by an example,

Get the Current Working Directory in Python

It will return the current working directory. In our system output was,

Let’s change the current working directory to ” .

Now let’s get the current working directory,

Now output in our system was,

because we changed the current working directory.

Complete example is as follows,

Output:

 

Python Resources

C++11 / C++14 Resources

Design Patterns Resources

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Do Subscribe with us for more Articles / Tutorials like this,