Multiple Ways To Get Current Working Directory In Python

If you are a programmer, you must have come across a requirement wherein you need to access the current working directory. The current working directory is the folder where your application is running from.

In this article, I’ll show you three different ways to get current working directory using Python.

Using os.getcwd

import os

w_dir = os.getcwd()

print(w_dir)

Using pathlib.Path.cwd

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store