os module print content of a directory 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: python program to print the contents of a directory using os module
import os
li = os.listdir(".")
print(li)
Example 3: list files python
import glob
files=glob.glob(given_path)
Example 4: read all files in folder python
import glob
print(glob.glob("/home/adam/*.txt"))