份可以說我有一個陣列numpy的,映射一個陣列到另一個
a = numpy.arange(8*6*3).reshape((8, 6, 3))
#and another:
l = numpy.array([[0,0],[0,1],[1,1]]) #an array of indexes to array "a"
#and yet another:
b = numpy.array([[0,0,5],[0,1,0],[1,1,3]])
其中「L」和「b」的長度相等, ,我想說
a[l] = b
這樣一個[0] [0]變成[0,0,5],a [0] [1]變成[0,1,0]等
它似乎工作正常時,維數組,但它給我的錯誤
ValueError: array is not broadcastable to correct shape
當我嘗試將其與3維陣列。
以 「一[郵編(* 1)]」 我得到這個錯誤:回溯(最近通話最後一個): 文件 「C:/Python32/test.py」,7號線,在 一個[郵編(* L )] = b IndexError:索引必須是一個整數或序列 –
感謝,用「元組(LT)」它的工作原理;) –