getting the color of pixels on the screen in Pytho

2019-09-07 11:00发布

问题:

I want to get the color of pixels on the screen in Python3.x. (example x,y) I work on windows. and using tkinter. But, It can't use PIL in Python 3.x.

How can i do this. Thank you.

回答1:

You can use PIL on Python3.x; there is a binary installer for Windows. The code might not work as is both on Python2.x and Python3.x:

try: import Image         # Python 2.x
except ImportError:
    from PIL import Image # Python 3.x

You could capture an area of the screen using an analog of grab() method.