【问题标题】:TypeError: unsupported operand type(s) for +=: 'int' and 'tuple'类型错误:+= 不支持的操作数类型:“int”和“tuple”
【发布时间】:2018-12-18 16:42:28
【问题描述】:

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

【问题讨论】:

标签: tuples


【解决方案1】:
self.imageGrayscalePixels[xCoordinate, yCoordinate] 

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

例子:

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

【讨论】:

    猜你喜欢
    • 2018-09-01
    • 1970-01-01
    • 2015-01-17
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 2021-06-16
    • 2014-06-16
    • 2014-03-16
    相关资源
    最近更新 更多