无法打印RGB(像素)的值

2024-05-12 06:03:04 发布

您现在位置:Python中文网/ 问答频道 /正文

代码如下:

from PIL import Image
img = Image.open("test.png")
pix = img.load()
(r,g,b) = pix[10,20]
print "R[%d],G[%d],B[%d]" % (r,g,b)

昨天天气很好。现在如果我运行它:

$ python test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    (r,g,b) = pix[10,20]
TypeError: 'int' object is not iterable

我不知道为什么它不起作用了。 任何帮助都将不胜感激

编辑:解决方法:sudo apt get install--重新安装python映像


Tags: 代码frompytestimageimportimgpil