how to list contents of a directory in python code example
Example 1: get list of folders in directory python
import os
my_list = os.listdir('My_directory')
Example 2: python get list of files in directory
from os import listdir
file_list = listdir(folder_path)
Example 3: list files python
#get all .txt files in my_path
import glob
my_path='/home/folder/'
files=glob.glob(my_path+'*.txt')