Python批量提取文件夹里的图片名称

import os
from PIL import Image
import openpyxl

image_folder = "your_image_folder_path"
image_list = []

for filename in os.listdir(image_folder):
    if filename.endswith(".jpg") or filename.endswith(".png"):
        image_list.append(filename)

wb = openpyxl.Workbook()
ws = wb.active

for i in range(len(image_list)):
    ws.cell(row=i+1, column=1, value=image_list[i])

wb.save("image_file_names.xlsx")

你可能感兴趣的:(python,常见问题)