files_in_dir_01.py

# =========================================================
# list the files and directories in a directory and
# its sub-directory
# ---------------------------------------------------------
# I is used to limit the  number of sub-directories
# processed
# =========================================================

from os import walk

rootdir = './'

i = 0
for path,dirs,files in walk(rootdir):
    i += 1
    if i > 1:
        break
    print('----------')
    print('path = {}'.format(path))
    print('dirs = {}'.format(dirs))
    print('files = {}'.format(files))