python 图像存储路径批量读取

读取文件夹中图像路径并写入列表中

import os
path = 'H:\\BaiduNetdiskDownload\\train_dog_cat'
for dirpath,dirnames,filenames in os.walk(path):
    image=[]
    for filename in filenames:
        img=os.path.join(dirpath,filename)
        image.append(img)
    print(image)

 

你可能感兴趣的:(python 图像存储路径批量读取)