OS Module in Python provides functions for interacting with the operating system. The OS comes with standard Python service modules. This module provides a portable way to use operating system specific functionality.
All functions in the os module raise OSError for invalid or unreachable file names and paths or other arguments that are of the correct type but are not accepted by the operating system.
os.getcwd () tells us the location of the current working directory (CWD).
Syntax: os.getcwd ()
Parameter: No parameter is required.
Return Value: This method returns a string which represents the current working directory.
Example # 1:
os.getcwd () to get the current working directory p >
Current working directory: C: UsersRajnishAppDataLocalProgramsPythonPython37
Example # 2:
os.getcwd () to get the current Python.Engineering working directory, which is root
Current working directory: /