Updated 4 years ago
Interacting with the OS and filesystem
The os
module in Python provides many functions for interacting with the OS and the filesystem. Let's import it and try out some examples.
import os
We can check the present working directory using the os.getcwd
function.
os.getcwd()
'/home/jovyan'
To get the list of files in a directory, use os.listdir
. You pass an absolute or relative path of a directory as the argument to the function.