如何舍入数组数组?我已经试过了 numpy.round

How can I round an array of arrays? I tried already numpy.round

[[391.88096195], [386.44174122], [378.13177006], [368.87926224]]

我的输出是上面的数组数组,我想将它四舍五入:

[[391.88], [386.44], [378.13], [368.87]]

您可以使用 list comprehension 语法:

>>> arr = [[391.88096195], [386.44174122], [378.13177006], [368.87926224]]
>>> arr = [[round(xx,2) for xx in aa] for aa in arr]
[[391.88], [386.44], [378.13], [368.87]]