for循环中取决于值的最后一次迭代

时间:2019-11-28 12:26:01

标签: python-3.x for-loop

这是代码:

for row in ws['F1:F100']:
            for cell in row:
                if cell.value == "Konto":
                    for x1 in range(13):

                        n1+=1
                        abc = cell.offset(row=n1).value

                        if abc == None or isinstance(abc, str) == True:
                            pass

                        else:
                            if abc == 306 or abc == 307:
                                 if c1 == 1:
                                     derp = input("derp?: ")
                                     c1 += 1
                                 if derp == "y":

                                    n2 +=1
                                    ws3.cell(row = n2, column = 2).value = konto

完成此代码后,我希望这样做,以便如果derp ==“ y”,它将弹出打开我编写的Excel文档。但是由于明显的原因,它希望根据找到的306和307的值多少来打开文档。在循环“完成”后,如何找到该循环的最后一个迭代并执行命令以打开文档?

0 个答案:

没有答案