This can be done with the listdir()
and getcwd()
methods of the os
module:
os.listdir("path")
: lists all files and directories underpath
which is provided as a stringos.getcwd()
: returns the full path to the current working directory
usage:
import os
os.listdir(os.getcwd())
The above will return a list
object with all file/directory names under the current working directory