TypeError:+ =不支持的操作数类型:“ int”和“ tuple”

时间:2018-12-17 11:56:00

标签: tuples

c4_part1 + = self.imageGrayscalePixels [xCoordinate,yCoordinate] TypeError:+ =不支持的操作数类型:“ int”和“ tuple”

1 个答案:

答案 0 :(得分:0)

self.imageGrayscalePixels[xCoordinate, yCoordinate] 

这将返回一个小礼堂。您不能将其添加到int中。您需要先从元组中提取值,然后再将其添加到c4_part1

示例:

x = self.imageGrayscalePixels[xCoordinate, yCoordinate]
c4_part1 += x[0] # 0 -> index of the value