📜  如何从python代码示例中的文件夹加载图像

📅  最后修改于: 2022-03-11 14:47:15.683000             🧑  作者: Mango

代码示例3
from PIL import Image
import os, os.path

imgs = []
path = "/home/tony/pictures"
valid_images = [".jpg",".gif",".png",".tga"]
for f in os.listdir(path):
    ext = os.path.splitext(f)[1]
    if ext.lower() not in valid_images:
        continue
    imgs.append(Image.open(os.path.join(path,f)))