Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get list of folders in directory python

import os 
my_list = os.listdir('My_directory')
Comment

list directory in python

from os import listdir

## Prints the current directory as a list (including file types)
print(os.listdir())
Comment

python list directories only

>>> [ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ]
['ctypes', 'distutils', 'encodings', 'lib-tk', 'config', 'idlelib', 'xml', 'bsddb', 'hotshot', 'logging', 'doc', 'test', 'compiler', 'curses', 'site-packages', 'email', 'sqlite3', 'lib-dynload', 'wsgiref', 'plat-linux2', 'plat-mac']
Comment

python3 list directories

import os

arr = os.listdir("c:/temp/")

print("
".join(arr))
Comment

PREVIOUS NEXT
Code Example
Python :: grid search cv 
Python :: ip condition in tpl 
Python :: fillna with mode pandas 
Python :: short form of if statement in python 
Python :: Get Current Date using today method 
Python :: registration of path in urls.py for your apps for views 
Python :: pyspark show all values 
Python :: python password hashing 
Python :: elif in django template 
Python :: create a python3 virtual environment 
Python :: python merge lists 
Python :: enable debug mode flask 
Python :: list of numbers 
Python :: iso date convert in python 
Python :: python square all numbers in list 
Python :: change colors markdown pyhton 
Python :: threading.Timer python recurrent 
Python :: how to convert fahrenheit to celsius in python 
Python :: scikit image 0.16.2 
Python :: render template in django 
Python :: python 2 deprecated 
Python :: use a dictionary to make a column of values 
Python :: flask api abort 
Python :: onehotencoder pyspark 
Python :: .text python 
Python :: hex python add 0 
Python :: plot background color matplotlib 
Python :: python list unique in order 
Python :: python create folder 
Python :: convert all items in list to string python 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =