我遇到了一个我无法解释的错误。以下是代码:'int'对象不能迭代列表列表
board = [[1, 2, 3],[1, 2, 3],[1, 2, 3]]
col = 0
col_nums = []
for rows in board:
col_nums += rows[col]
这给出'int'对象不是可迭代错误。 这工作虽然:
for rows in board:
print(rows[col])
我想col_nums = [1, 1, 1]
结束。它似乎并没有迭代任何整数,只是rows
,这是一个列表。我认为这可能与+=
有关。
我很惊讶,我没有看到这一点。谢谢 – qwr