python get all folders in directory

40

import os 
my_list = os.listdir('My_directory')
import os
subfolders = [ f.path for f in os.scandir(folder) if f.is_dir() ]
for path, subdirs, files in os.walk(root):
    for name in files:
        print os.path.join(path, name)

Comments

Submit
0 Comments