【发布时间】:2019-10-22 12:45:48
【问题描述】:
如果满足条件,我正在尝试将行值重新设置为前一行值。一旦满足条件,现有行将被删除。
for b in BR:
while i < cntRows:
rowValue= session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").GetCellValue(i,"ZCOMMENTS")
print(rowValue)
if rowValue!="Orphan Impound":
if debitAmt==disRcvAmt:
impMatch="Dollar Amount Matched"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellRow=i
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectedRows=i
session.findById("wnd[0]/tbar[1]/btn[13]").press()
i-=1
else:
i+=1
continue
当我使用 i-=1 并且当行计数器为 0 时它需要转到 b 中的下一项时,代码会崩溃。
如何在这两种情况下阻止崩溃。
谢谢任
【问题讨论】:
-
“代码崩溃”——哪个错误? “当行计数器为 0 时,它需要转到 b 中的下一项”——为什么你的
while不循环检查i == 0呢?i的初始值是多少? -
i==0 的初始值。我也检查了 cntRow = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").RowCount if cntRow==0: 我在 if 条件下添加了这个仍然不起作用。
-
没有错误,因为应用程序无法找到它并且代码处于尝试和除块中
标签: python-3.x sap-gui