Languages

Python - how to find current directory?

0 points
Asked by:
Dirask Community
6300

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:
Dirask Community
6300

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