python list content from directory code example
Example 1: get files in directory python
import os
files_and_directories = os.listdir("path/to/directory")
Example 2: how to see directory from os module
import pathlib
# define the path
currentDirectory = pathlib.Path('.')
# define the pattern
currentPattern = "*.py"
for currentFile in currentDirectory.glob(currentPattern):
print(currentFile)