Iterating through a multidimensional array in Python

前端 未结 7 1518
旧巷少年郎
旧巷少年郎 2020-12-13 13:35

I have created a multidimensional array in Python like this:

self.cells = np.empty((r,c),dtype=np.object)

Now I want to iterate through all

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 14:15

    How about this:

    import itertools
    for cell in itertools.chain(*self.cells):
        cell.drawCell(surface, posx, posy)
    

提交回复
热议问题