2016-05-01 28 views

回答

2

當你宣佈你的清單obj_list = []你的事情列出來,但是Python不知道自己應該何去何從。當你這樣做時你說你列表中的i這個項目是一個數組,但你還沒有明確說明是這種情況。所以,我會改變你的代碼看起來像這樣:

for i in range(0,100): 
    obj_list.append([]) # Append an element to the list 
    for j in range(0,100): 
     orient = np.random.randint(180) 
     obj_list[i].append([cell_id, orient]) # append an element to the sub list 
     cell_id += 1 
+0

錯誤仍然存​​在... – user3408085

+0

@ user3408085哎呦對不起 - 我糾正我的答案。被精神上丟失在JavaScript的土地,忘記完全轉換爲蟒蛇:) – winhowes

相關問題