Read files in subdirectories of parent directory

# The os.listdir() method is used to return a list of the names of the files or folders contained in the specified folder
    files = os.listdir(path)
    for file in files:
        # os.path.join() returns after combining multiple paths
        paths = os.path.join(path, file)
        chilfiles = os.listdir(paths)
        # loop through all files
        for file in chilfiles:
            print(file)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324943768&siteId=291194637