Answer the question
In order to leave comments, you need to log in
Python3 os.path.abspath(os.path.dirname(__file__)) returns wrong?
I need to return the very beginning of the site for different OSes,
Google writes that this should return it, os.path.abspath(os.path.dirname(__file__))
i.e. if the site is located on D: / python_proj / mysite.com
Then it should return this address
But it grows the address of the folder where the script that executes this lies command
Answer the question
In order to leave comments, you need to log in
Which is absolutely logical. You are asking for the location of the file where you are executing the code: os.path.dirname(__file__). If you need to get the value of the top level address:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question