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

--

--

--

I’m C# Corner MVP, mentor, speaker, YouTuber & developer. YouTube: https://www.youtube.com/channel/UCQVOeT4i5nezvPG_xvIFzdQ Blog: http://www.shwetalodha.in

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Recap of 2021 — A Quick Time Capsule

How to make Scrum adoption work for Business Goals, not for coaches only?

Introducing KarmaChest

Guide to SaaS Vendor Management — Blissfully

What I learned Mar 22nd — Mar 28th

Step 5.5 — Organizing Enemy Spawn Clutter

Top Features To Look For In Every Workflow Automation Tool

Structure of Workflow

Why You Shouldn’t Consider Xamarin Native for Your Next Project

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
Shweta Lodha

Shweta Lodha

I’m C# Corner MVP, mentor, speaker, YouTuber & developer. YouTube: https://www.youtube.com/channel/UCQVOeT4i5nezvPG_xvIFzdQ Blog: http://www.shwetalodha.in

More from Medium

Get User Name And Password At Runtime Using Python

Automate Excel to SQL insert query in Python

These Tips will help you to install libraries in python more efficiently

python subprocess