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:

 

Click Here to Subscribe for more Articles / Tutorials like this.