1
比方说,我有一个数组x
和数组mask
的蒙版。我想用np.copyto
使用mask
来写入x
。有什么办法可以做到这一点?只是试图使用copyto
不起作用,我想,因为蒙面x
是不可写的。写入numpy中的蒙面数组
x = np.array([1,2,3,4])
mask = np.array([False,False,True,True])
np.copyto(x[mask],[30,40])
x
# array([1, 2, 3, 4])
# Should be array([1, 2, 30, 40])
会不会'X [面具] = [30,40]'工作? – SvbZ3r0