list files in dir python s code example
Example 1: python list files in current directory
import os
files = os.listdir('.')
print(files)
for file in files:
# do something
Example 2: get list of files in directory python
import os
path = '/folder1/folder2/'
files = os.listdir(path)