我阅读了很多文章,但是找不到其他条件的解决方案。 可悲的是我的循环永不停止。似乎并没有反复检查 project.IsInProgress()= True
我想每隔两秒钟检查一次,如果我的陈述仍然是True,如果不再是True,我想中断重复并执行打印陈述。
我想问题是它两秒钟都没有运行该功能。但我不知道该如何处理。
check_status = project.IsInProgress()
while check_status:
print('Render in progress..')
time.sleep(2)
else:
print('Render is finished')
答案 0 :(得分:1)
尝试一下:
while project.IsInProgress():
print('Render in progress..')
time.sleep(2)
print('Render is finished')
或者,如果您愿意:
check_status = project.IsInProgress()
while check_status:
print('Render in progress..')
time.sleep(2)
check_status = project.IsInProgress()
print('Render is finished')
答案 1 :(得分:0)
您的代码仅在代码开头检查一次进行中,如果为True,则循环将永远持续下去。 为了检查每次迭代的状态,请尝试:
while project.IsInProgress() :
print('Render in progress..')
time.sleep(2)
else:
print('Render is finished')