os.getcwd()
os.getcwd() method tells us the location of the current working directory (CWD).
Example:
Python3
# Python program to explain os.getcwd() method # importing os module import os # Get the current working # directory (CWD) cwd = os.getcwd() # Print the current working # directory (CWD) print ( "Current working directory:" , cwd) |
Output:
Current working directory: /home/nikhil/Desktop/gfg
10 Python File System Methods You Should Know
While programming in any language, interaction between the programs and the operating system (Windows, Linux, macOS) can become important at some point in any developer’s life. This interaction may include moving files from one location to another, creating a new file, deleting a file, etc.