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