Answers for "python get list of folders in directory"

18

python list files in current directory

import os

files = os.listdir('.')
print(files)
for file in files:
  # do something
Posted by: Guest on November-04-2020
14

get list of folders in directory python

import os 
my_list = os.listdir('My_directory')
Posted by: Guest on June-08-2020
1

how to get all folders on path in python

os.walk(directory)
[x[0] for x in os.walk(directory)]
Posted by: Guest on February-10-2020
0

list directory in python

from os import listdir

## Prints the current directory as a list (including file types)
print(os.listdir())
Posted by: Guest on April-23-2020

Code answers related to "python get list of folders in directory"

Python Answers by Framework

Browse Popular Code Answers by Language