Numpy - 在数组结果中显示十进制值

ric*_*rdo 1 python numpy

我如何计算一个python numpy数组或我所有的计算小数而不是跳过像.

>> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]]).

>> C = numpy.array ([[7,8,9], [1,2,3], [4,5,6]]).

>> A / C

array ([[0, 0, 0],
       [4, 2, 2],
       [1, 1, 1]])
Run Code Online (Sandbox Code Playgroud)

但是在第一个向量中不必给出绝对零 [0.143, 0.250, 0.333]

int*_*jay 6

要避免整数除法,请使用numpy.true_divide(A,C).您还可以将from __future__ import division文件顶部放置为默认此行为.