有没有一种方法可以使用python将屏幕截图的输出保存在列表中

问题描述 投票:0回答:1

我编写了Python代码以随机间隔获取屏幕快照,现在我正尝试将屏幕快照保存在列表中,以便能够将其打印出来

这是我的代码

def takeScreenshot (Request):
    count=0
    name = random.randrange(1, 1000)
    full_name = str(name) + ".jpg"
    for i in full_name:
        count = count + 1
    myScreenshot = pyautogui.screenshot()
    myScreenshot.interval = 100
# generate a random time between 120 and 300 sec
    random_time = random.randrange(20, 30)
# wait between 120 and 300 seconds (or between 2 and 5 minutes)
    time.sleep(random_time)
    myScreenshot.save((r'C:\Users\ZainbaMuhdYunus\Desktop\shots2\shot') + full_name)
    location = []
    location.append(myScreenshot)

    # keeps doing count
counter = 0
while 1:
     counter = counter + 1
     data = {}
     takeScreenshot(data)
python pyautogui
1个回答
0
投票

这是我已经查看过的问题的审阅代码,也许现在可以自我解释

import random
import pyautogui
import tkinter as tk
from tkinter import filedialog

root= tk.Tk()
def takeScreenshot ():
    # count=0
    name=random.randrange(1,1000)
    full_name=str(name) + ".jpg"
    myScreenshot = pyautogui.screenshot()
    myScreenshot.interval = 100
# generate a random time between 120 and 300 sec
    random_time = random.randrange(2,10)
# wait between 120 and 300 seconds (or between 2 and 5 minutes)
    time.sleep(random_time)
    myScreenshot.save((r'C:\Users\ZainbaMuhdYunus\Desktop\shots2\shot') + full_name)

    # keeps doing count

counter=0
while 1:
    takeScreenshot()```
© www.soinside.com 2019 - 2024. All rights reserved.