openpyxl识别excel中的图片并保存
from openpyxl import load_workbook
workbook = load_workbook(r"C:\Users\ben_ma\Desktop\新建 XLSX 工作表.xlsx")
num = 1
for sheet_name in workbook.sheetnames:
worksheet = workbook[sheet_name]
for image in worksheet._images:
img_data = image._data()
# 保存图像的二进制数据为文件
with open(f'image_{num}.jpg', 'wb') as f:
f.write(img_data)
num += 1