Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 1.96 KB

OS_Get_current_working_directory.md

File metadata and controls

43 lines (25 loc) · 1.96 KB



Template request | Bug report | Generate Data Product

Tags: #os #python #snippet #operations #operatingsystem

Author: Florent Ravenel

Description: This notebook demonstrates how to get the current working directory using os module. The main purpose of the OS module is to interact with your operating system. The primary use I find for it is to create folders, remove folders, move folders, and sometimes change the working directory. You can also access the names of files within a file path by doing listdir(). We do not cover that in this video, but that's an option.

References:

Input

Import libraries

import os

Model

Get current working directory

The os.getcwd() function returns the current working directory of the process.

# Get the current working directory
cwd = os.getcwd()

Output

Display result

# Print the current working directory
print(cwd)