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

pythonimport os

os.getcwd()

Example

Let's find out our working directory:

pythonimport os

print(os.getcwd())

The result of the executed code:

pythonC:\python

See also

  • method listdir of module os,
    which returns a list of files in the working directory
  • method makedirs of module os,
    which creates folders
  • method mkdir of module os,
    which creates one folder
  • method path.exists of module os,
    which checks the existence of a path
  • method scandir of module os,
    which iterates through the files in a folder
  • method stat of module os,
    which returns the status of the path