使用 ndarray.reshape That said, newaxis is clearer and should be preferred. Also, a case can be made that newaxis is more future proof. See also: Numpy: Should I use newaxis or None?>>> A - mean.reshape((mean.shape[0]), 1)array([[-1., 0., 1.], [-1., 0., 1.], [-1., 0., 1.], [-1., 0., 1.]])直接更改 ndarray.shape 您也可以直接更改mean的形状.>>> mean.shape = (mean.shape[0], 1)>>> A - meanarray([[-1., 0., 1.], [-1., 0., 1.], [-1., 0., 1.], [-1., 0., 1.]]) 这篇关于从numpy矩阵中删除均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-24 18:17