一行循环内的错误“'int'对象不可迭代”

时间:2021-06-17 15:39:21

标签: loops syntax

为什么这一行会出现错误,当这些都没有返回数字时,“int”类与什么有关系?

choice([cell for cell in row for row in self.rows if not cell.is_num and not cell.is_bomb]).open_cell()
Traceback (most recent call last):
  File "E:\Programming\Python\QT\Mineswiper\minesweeper v2.py", line 148, in <module>
    window = MainWindow()
  File "E:\Programming\Python\QT\Mineswiper\minesweeper v2.py", line 144, in __init__
    choice([cell for cell in row for row in self.rows if not cell.is_num and not cell.is_bomb]).open_cell()
TypeError: 'int' object is not iterable

0 个答案:

没有答案