假设我有一个数组
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
需要让a[0][0]变成[0,0,5],a[0][1]变成[0,1,0]等等。
当我使用一维数组时,似乎运行良好,但是它给出了错误提示。
ValueError: array is not broadcastable to correct shape
当我尝试使用一个三维数组时。