2024-09-28 05:28:22 发布
网友
我想用PIL创建一个python脚本,在使用时保存一个屏幕截图,但我希望它在使用时保存带有单个名称的屏幕截图。例如:截图1、截图2等
我已经有代码,保存一个sceenshot,但在第二次使用它覆盖了最后一个屏幕截图
from PIL import ImageGrab from PIL import Image import time time.sleep(1) img = ImageGrab.grab() img.save ('screenshot.jpg', 'JPEG')
import datetime count=0 while(True): count+=1 str_time=datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S") img.save("screenshot_"+str_time+".jpg",'JPEG') time.sleep(1)
使用上述代码递增计数器并保存图像
使用上述代码递增计数器并保存图像
相关问题 更多 >
编程相关推荐