Answers for "python list content from directory"

12

get files in directory python

import os
files_and_directories = os.listdir("path/to/directory")
Posted by: Guest on June-12-2020
0

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)
Posted by: Guest on January-20-2021

Code answers related to "python list content from directory"

Python Answers by Framework

Browse Popular Code Answers by Language