在使用 pyautogui 检查图像是否不是屏幕的一部分时,我尝试了以下操作:
a = True
while a is True:
a = pyautogui.locateOnScreen('image.png')
print ("No this image.')
好像不太好用。
正确的做法是什么?
将其置于
for
循环中,不断检查图像是否存在,一旦消失,退出循环。
for _ in range(100):
time.sleep(1)
a = pyautogui.locateOnScreen('image.png')
if a == None:
print('No this image.')
break