如何在导入的excel文档中循环浏览并获取字符串值,并使用该值命名最终的图像输出

问题描述 投票:0回答:1

我想知道如何遍历excel列,并在每一行中获取str值,并将其用于命名最终图像输出。目前,我将最终图像命名为img1,img2,img3等,但要在行中使用str值来命名。

final_qr.save(r'C:\ xxxxxxxxxxxxx \img'+ str(i) + '.png')
python for-loop openpyxl naming
1个回答
0
投票

使用pylightxl相当简单,请参阅文档https://pylightxl.readthedocs.io/en/latest/quickstart.html

import pylightxl as xl

workbook = xl.readxl(‘yourexcelfile.xlsx’)

for cell in workbook.ws(‘Sheet1’).col(1):
    final_qr.save(r'C:\ xxxxxxxxxxxxx \img'+ str(cell) + '.png')
© www.soinside.com 2019 - 2024. All rights reserved.