Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get list of folders in directory python

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

python get all folders in directory

import os
subfolders = [ f.path for f in os.scandir(folder) if f.is_dir() ]
Comment

list files in directory python

import os
print(os.listdir('/path/to/folder/to/list'))
Comment

get list of files in directory python

import os
path = '/folder1/folder2/'
files = os.listdir(path)
Comment

get list file in folder python

lstJson = [f for f in os.listdir(str(self.pathJson)) if f.endswith('.json')]
        return lstJson
Comment

python get list of files in directory

from os import listdir
file_list = listdir(folder_path)
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 files in directory

import os
folder_path = "./folder-path"

for path, currentDirectory, files in os.walk(folder_path):
    for file in files:
        if not file.startswith("."):
            print(os.path.join(path, file))
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

python list files in directory

from os import walk

f = []
for (dirpath, dirnames, filenames) in walk(mypath):
    f.extend(filenames)
    break
Comment

python3 list directories

import os

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

print("
".join(arr))
Comment

PREVIOUS NEXT
Code Example
Python :: convert date time to date pandas 
Python :: python hashlib.sha512() 
Python :: importlib.reload not working 
Python :: select categorical columns pandas 
Python :: pandas loop through rows 
Python :: python clean recycle bin 
Python :: python run server 
Python :: python listdir with full paths 
Python :: update python ubuntu 
Python :: download pdf from url python 
Python :: python strip non numeric in string 
Python :: days of week 
Python :: python sort a list of tuples 
Python :: open pkl file python 
Python :: How to config your flask for gmail 
Python :: convert negative to zero in list in python 
Python :: index in zip python 
Python :: python count number of zeros in a column 
Python :: change date format python 
Python :: plot roc curve for neural network keras 
Python :: pandas dataframe set datetime index 
Python :: create pandas dataframe with random numbers 
Python :: discord py bot status 
Python :: get a list of column names pandas 
Python :: image in cv2 
Python :: plot function in numpy 
Python :: jupyter notebook dark theme 
Python :: install googlesearch for python 
Python :: how to plot count on column of dataframe 
Python :: height width image opencv 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =