【发布时间】:2018-10-11 10:12:05
【问题描述】:
我正在尝试编写一个函数,它将图像作为输入,然后返回一个函数,该函数将采用索引并返回该索引的颜色。这是我到目前为止得到的:
def generator(image):
def index2color(index1):
return image[index1]
return index2color
让我们试试吧:
generator2 = generator("flower.jpg")
print (generator2((3)))
>>> w
所以这将返回字符串中的索引,而不是图片的索引。任何建议将不胜感激!
【问题讨论】:
-
对图像进行操作即可。否则谷歌一下,互联网上有很棒的教程。