python - How to get list of subdirectories names -


this question has answer here:

there directory contains folders files of different formats.

import os  my_list = os.listdir('my_directory') 

will return full content of files , folders names. can use, example, endswith('.txt') method select text files names, how list of folders names?

try checking directories, while assembling list.

import os output = [di di in os.listdir('foo') if os.path.isdir(os.path.join('foo',di))] 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -