本文介绍了pyautogui.locateOnScreen() 用于多个图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于多个图像和一堆图像,您将如何执行pyautogui.locateOnScreen()?

How would you do pyautogui.locateOnScreen() for multiple images a bunch of images?

推荐答案

试试这个:

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))

这个问题类似于另一个一个,我发布了相同的答案两个地方.

This question is similar to another one, I posted the same answer in both places.

这篇关于pyautogui.locateOnScreen() 用于多个图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 05:57