list of only directories python code example
Example 1: get list of folders in directory python
import os
my_list = os.listdir('My_directory')
Example 2: list only directories
# List directories under the current working directory.
ls -l | grep "^d"
# List directories under the current working directory and
# include hidden folders
ls -la | grep "^d"