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? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -