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
Post a Comment