Languages

Python - how to find current directory?

0 points
Asked by:
Hiba-Tate
368

How do I find the current directory with Python?

I want to get the full path to the directory a Python file is contained in.

1 answer
0 points
Answered by:
Hiba-Tate
368

To get the current directory path import os module and use getcwd() method.

import os

current_directory = os.getcwd()
print(current_directory)  # C:\Users\user\PycharmProjects\...
0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join