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,



Python Recommendations:

C++ & C++11 Recommendations:

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.

Subscribe with us to join 1500+ Python & C++ developers, to get more Tips &  Tutorials like this.