as in Python - the program to find out the path to the current directory with the script. I know that this requires an OS library, but there are so many different classes and functions that you can kill half a day in search.
on5fydu8@gmail.com
·
01.01.1970 03:00
Current Directory in Python
on5fydu8@gmail.com
·
01.01.1970 03:00
"
If you start the script c: \ scripts \ script.py from
D: \ Work & Gt; \ Scripts \ Script.py
-
d: \ work & mdash; & nbsp; this is the current working directory at the time of the start of the script. File -
c: \ scripts& mdash; & nbsp; this is a directory with a script.
Current working directory h3>
Retus, where CWD This is Current Working Directory ("Current Labor Directory" ""). The platforms depends) ITD & mdash; do not invent your ways if you are not aware of all the consequences of a possible change in the behavior of the function. Preferably only --obvious way to do it.
by default relative ways use this directory, therefore obviously call os.getcwd () It is necessary to .
retus the way to the current directory as an object with various useful and convenient methods such as such as .glob ('**/*. Py') .
The directory with a script h3>
The current working directory may differ from the directory with the current python script . __ File __ . Text:
import importlib.resourcestext = Importlib.Resources.Read_text (, import app on class # $ pip install Appdirs user_data_dir = appdirs.user_data_dir (, "" Who created "" "" "" "" "" "" "" "" " Platforms (Windows, MacOS, Linux) use different agreements, appdirs allows you not to produce entities and use suitable directory on each platform.