我从事 Python 图像库项目只是为了好玩。但是,我无法弄清楚为什么我不断收到此代码的“列表不可调用”错误:
def __computeTopColors(self):
temp1, temp2, temp3, temp4 = [], [], [], []
max = (0,0,0)
for v in self.PixelVals:
if (v[0] > max[0]) and (v[1] > max[1]) and (v[2] > max[2]):
max = v
min = (1000,1000,1000)
for v in self.PixelVals:
if (v[0] < min[0]) and (v[1] < min[1]) and (v[2] < min[2]):
min = v
for pval in self.PixelVals:
if (min[0] <= pval[0] <= int(((max[0])/2))) and (min[1] <= pval[1] <= int(((max[1])/2))):
temp1.append(pval)
return temp1
def temp(self):
print self.temp
注意:这实际上是类(class)的摘录,但我认为这不是特别相关。 self.PixelVals
是形式为 (R,G,B) 的列表元组。 self.temp 是我用来测试 __computeTopColors
方法的临时方法;我在 __init__
中将 self.temp 设置为等于 self.__computeTopColors
。
回溯:
Traceback (most recent call last):
File "fiveColors.py", line 39, in <module>
a.temp()
第 39 行是我的代码块中的最后一行。
最佳答案
您已经在某处用列表隐藏了 int
。别那样做。并停止在 min()
和 max()
的阴影下。
关于python - "List object is not callable"Python 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13943916/