python-3.x - 满足条件时,将行值设置为 while 循环中的前一个值
问题描述
如果满足条件,我正在尝试将行值重新设置为前一行值。一旦满足条件,现有行将被删除。
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 中的下一项时,代码会在返回到上一行时崩溃。
我如何在这两种情况下停止崩溃。
谢谢任
解决方案
找出解决方案并通过添加此部分停止崩溃
cntRow=session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").RowCount
if cntRow <0:
session.findById("wnd[0]").sendVKey(3)
session.findById("wnd[0]").sendVKey(2)
break
elif cntRow==i:
break
elif cntRow>0:
if k<0:
i=-1
else:
i==k
推荐阅读
- reactjs - 使用 React 的 Bot Framework 语音到文本集成问题
- sqlite - 如何在 Sqflite for Flutter 中使用准备好的语句
- java - 尽管不使用锁定,比较和设置如何工作
- java - Java 8:使用 andThen() 和 apply() 方法时 BiFunction 如何工作
- cassandra - Cassandra 3.10 - 泄漏检测和流失败
- java - 用 Java 创建 kafka 主题不起作用
- python - csv 文件在“w”模式下不写入
- c - 在C中获取小写的文件扩展名
- javascript - 如何在 j 查询中获取变量/不恒定的复选框 id 和值?
- java - 在@Transactional注释下的数据库中应用触发器后如何修复空指针异常?