我的程序使用下面的代碼插入名爲Field
到被動態創建一個多維數組(至少我認爲這將是創建)一個對象:的Python 2多維數組創建
for x in range(self.width):
for y in range(self.height):
self.board_fields[x][y] = Field()
所以board_fields
沒有動態創建,我得到了錯誤:
AttributeError: 'Board' object has no attribute 'board_fields'
我應該如何定義把值到它之前,多維數組?
你肯定的是,上述代碼執行得到?因爲,這個錯誤讓我覺得,python甚至不知道'board_fields'是什麼。 – thefourtheye