通过Python实现直接截屏或截取特定区域的屏幕截图的功能,具体实现如下:
# Grab Screenshot
# pip install pyautogui
# pip install Pillow
from pyautogui import screenshot
import time
from PIL import ImageGrab
# Grab Screenshot of Screen
def grab_screenshot():
shot = screenshot()
shot.save('my_screenshot.png')
# Grab Screenshot of Specific Area
def grab_screenshot_area():
area = (0, 0, 500, 500)
shot = ImageGrab.grab(area)
shot.save('my_screenshot_area.png')
# Grab Screenshot with Delay
def grab_screenshot_delay():
time.sleep(5)
shot = screenshot()
shot.save('my_screenshot_delay.png')
标签:截图,shot,screenshot,Screenshot,area,Python,功能,grab,Grab
From: https://blog.51cto.com/u_15944471/6051020