以下是我用来提取存储在 G7 单元格中的图像的代码:
def getImageAttachment():
ExcelBook = openpyxl.load_workbook("F:\\MSL Automation Framework\\msl.test\\TestDataExcel.xlsx")
sheet = ExcelBook.active
image_loader = SheetImageLoader(sheet)
image = image_loader.get('G7')
test_ImageAttachment = [{sheet['G6'].value: image}]
return test_ImageAttachment
但是 TypeError: object of type 'JpegImageFile' has no len() 运行测试时抛出错误。下面附上截图:
请帮帮我。我不想直接提供图像路径以避免硬编码,而是想从 excel 表中获取图像。