首页 > 解决方案 > 如何从字母数字中获取数字输出(Pyautogui)

问题描述

你怎么能只得到数字输出

pyautogui.locateOnScreen('Capture.png')

如果pyautogui在屏幕上找不到图片,您将获得输出;无,或者如果pyautogui在屏幕上找到图片,它将给出如下输出;框(左=1416,上=562,宽=50,高=41)

是否可以仅从输出中获取数字?

标签: python

解决方案


参考文档pyautogui可以使用:

location = pyautogui.locateOnScreen('Capture.png')
if location != None:
    x, y, w, h = location

或者:

if location != None:
    x, y, w, h = location.left, location.top, location.width, location.height

推荐阅读