Source Code:
(back to article)
import os path = '/path/to/directory' txt_files = [file for file in os.listdir(path) if file.endswith('.txt')] for file in txt_files: print(file)
Result:
Report an issue