Why does this line of code produce the TypeError: 'tuple' object cannot be interpreted as an integer

Why does this line of code produce the TypeError: 'tuple' object cannot be interpreted as an integer

我正在尝试为某些监控软件打印屏幕截图的颜色值。为此我使用了 autopy,它在他们的网站上有以下命令来提取像素的 rgb 值。

autopy.color.hex_to_rgb(autopy.screen.get_color(100, 100))

我对 Python 或 autopy 了解不多,非常感谢您的帮助

编辑:这是完整的错误消息:

回溯(最后一次调用): 文件 "Scr.py",第 12 行,位于 autopy.color.hex_to_rgb(autopy.screen.get_color(100, 100)); 类型错误:'tuple' 对象不能解释为整数

autopy.screen.get_color(100, 100) 你得到像 (128, 128, 128) 这样的元组 它已经在 RGB 中。如果你需要十六进制,试试这个:

autopy.color.rgb_to_hex(*autopy.screen.get_color(100, 100))

编辑: (2019.09.14)

几周前我就这个问题给作者发了消息

参见:mistake in example autopy.color.hex_to_rgb(autopy.screen.get_color(1, 1))

现在他回答说在下一个主要版本中这将像教程中那样工作。