The getcwd method of os the module
The getcwd method of the os module returns the current working directory. We do not specify anything in the method parameter.
Syntax
import os
os.getcwd()
Example
Let's find out our working directory:
import os
print(os.getcwd())
The result of the executed code:
C:\python
See also
-
method
listdirof moduleos,
which returns a list of files in the working directory -
method
makedirsof moduleos,
which creates folders -
method
mkdirof moduleos,
which creates one folder -
method
path.existsof moduleos,
which checks the existence of a path -
method
scandirof moduleos,
which iterates through the files in a folder -
method
statof moduleos,
which returns the status of the path