Let’s say that I have a python script a.py in /A/B/a.py, and it’s in the PATH environment variable. The current working directory is /X/Y/, and it’s the directory where I call the /A/B/a.py.
- In a.py, how to detect /X/Y/? I mean, how to know in which directory the python call is made?
Advertisement
Answer
You can get the current working directory with:
os.getcwd()