在Windows上截屏并保存?

时间:2016-07-16 11:24:40

标签: python save screenshot

我想用截图,使用python,(仅限Windows)并保存它! 我正在使用pyscreenshot库和PIL

import numpy as np
import matplotlib.pyplot as plt
from PIL import ImageGrab
import pyscreenshot as ImageGrab

img = ImageGrab.grab()


plt.imshow(img, cmap='gray', interpolation='bicubic')
plt.save('img.png')

1 个答案:

答案 0 :(得分:0)

试试这段代码:

import pyscreenshot as ImageGrab

# fullscreen
im=ImageGrab.grab()
im.show()

# part of the screen
im=ImageGrab.grab(bbox=(10,10,500,500))
im.show()

# to file
ImageGrab.grab_to_file('im.png')