python - pyautogui.locateOnScreen() 用于多个图像?
问题描述
你会如何pyautogui.locateOnScreen()
处理多个图像一堆图像?
解决方案
试试这个:
import os
import pyautogui as py
image_list = []
# Get list of all files in current directory
directory = os.listdir()
# Find files that end with .png or .jpg and add to image_list
for file in directory:
if file.endswith('.png') or file.endswith('.jpg'):
image_list.append(file)
# Loop through list to find all the images
for image in image_list:
print(image)
print(py.locateOnScreen(image))
这个问题与另一个问题相似,我在两个地方都发布了相同的答案。
推荐阅读
- c# - 在服务器端 mvc 上调用 javascript 函数
- react-native - 围绕另一个圆圈制作一个圆圈的动画
- scala - 如何将递归函数转换为尾递归版本?
- javascript - 如何使用 axios 和 javascript 为单个元素传递 url 的 id 值
- javascript - 如何使用 Reactjs 使用 oauth2 Password Grant 对用户登录进行身份验证?
- mongodb - Mongo 位置投影 $
- php - Laravel:是否可以将 Session 作为依赖项注入?
- reactjs - SyntaxError:缺少类属性转换
- react-native - 如何修复 React-Native 中的“路由 'Principal' 的组件必须是 React 组件”错误
- influxdb - 为什么这个简单的流入选择查询返回一个空结果?