How to check what is the current working directory with os in Python

1 min

It might come in handy to be able to check what is the directory we are running the script from.

Especially when you try to find that one file that contains your data or even the library you are desperately trying to run.

Here is the code

import os

print(os.getcwd())
Here is how to get the path of the current directory

Here you are! You now know how to check what is the current working directory with os in Python.

More on fundamentals

If you want to know more about Python fundamentals without headaches... check out the other articles I wrote by clicking just here:

Fundamentals - The Python You Need
We gathered the only Python essentials that you will probably ever need.