from PIL import ImageGrab
功能:ImageGrab模塊能將屏幕或剪切板的內容複製到PIL圖像內存。
The ImageGrab module can be used to copy the contents of the screen or the clipboard to a PIL image memory.
問題:The current version works on macOS and Windows only.
解決方法:使用pyscreenshot庫,它是Linux系統的ImageGrab替代品
import pyscreenshot as ImageGrab
參考博客:
http://www.pythonheidong.com/blog/article/145595/
https://pillow.readthedocs.io/en/stable/reference/ImageGrab.html