2016-07-16 48 views
0

我想截圖,使用python,(僅限Windows)並保存! 我使用pyscreenshot庫和PIL在Windows上截圖並保存?

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') 
+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') 
+0

我收到了很多錯誤: - 請參閱 –

+0

我正在使用pybram從jetbrains和py 3.5 –

+1

我不能發佈整個錯誤,但它是這樣的: - 嘗試開始一個新的過程之前, 當前進程已完成引導階段。 這可能意味着你不使用叉子,開始您的 子進程,你已經忘記了使用正確的成語 主要模塊: 如果__name__ ==「__main__」: freeze_support() ... 如果程序 不會被凍結以生成可執行文件,則可以省略「freeze_support()」行。 –

相關問題