all_filenames = glob.glob("/home/lynaza/Desktop/Quinn/lda/檢察官起訴書/*.txt")

#return only filename (may contain not only duoi file)
 import os
 arr = os.listdir("/home/lynaza/Desktop/Quinn/lda/檢察官起訴書")

import cv2
import os
import glob

def load_images_name(path):
    list_1 = glob.glob(path+'/*.tif') # depth of 1 folder
    list_2 = glob.glob(path+'/*/*.tif') # depth of 2 folder
    list_3 = glob.glob(path+'/*/*/*.tif')  # depth of 3 folder
    list_4 = glob.glob(path+'/*/*/*/*.tif')  # depth of 4 folder
    images_path = list_1 +list_2 +list_3 + list_4

    return images_path

images = load_images_name("/home/lynaza/Desktop/traindata/test")
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter