如何让python识别像素颜色代码?

问题描述 投票:0回答:1

我正在尝试让 python 识别屏幕上的特定像素颜色代码,有 4 个选项,如果你想知道,我使用 1366x768 显示分辨率,我也使用 Visual Studio Code

识别特定颜色代码像素的代码/插件

python uniqueidentifier uicolor
1个回答
0
投票

一些代码有助于理解您想要做什么,但据我了解,您想要获取屏幕上特定像素的 RGB 颜色。

为此,您可以使用 pyautogui 库。
像这样安装:

pip install pyautogui

或者:

python3 -m pip install pyautogui

这是一个示例程序:

import pyautogui as auto

x = 200 # replace with X coordinate of the pixel
y = 150 # replace with Y coordinate of the pixel

screenshot = auto.screenshot() # take a 'screenshot'
pixel = screnshot.getpixel(x, y) # get the pixel at position x, y

print(pixel)

如果您不太确定我的意思,请查看此堆栈溢出问题以了解更多信息。

希望这有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.