all Python 3osfunction
os.getcwd
os — working directory
Return the current working directory as a str.
Syntax
os.getcwd() -> str
The current directory belongs to the whole process, not a thread or module, so relative paths in a program depend on where it was launched from. For files next to the script pathlib.Path(__file__).parent is more reliable. If the current directory has been deleted, getcwd raises FileNotFoundError.
Examples
import os
print(isinstance(os.getcwd(), str)) # → True
print(type(os.getcwd())) # → <class 'str'>
start = os.getcwd() # запомнить текущий каталог
See also
Open in the full glossarydocs.python.orgReport an inaccuracy