Translate

Python ---- list all the files in a directory

 Code:

import os

for (root, dirs, file) in os.walk(path):
    for f in file:
        if '.txt' in f:
            print(f)

No comments:

Post a Comment