How to pretty-print a numpy.array without scientific notation and with given precision?

后端 未结 14 2193
臣服心动
臣服心动 2020-11-22 04:28

I\'m curious, whether there is any way to print formatted numpy.arrays, e.g., in a way similar to this:

x = 1.23456
print \'%.3f\' % x
         


        
14条回答
  •  鱼传尺愫
    2020-11-22 04:48

    I use

    def np_print(array,fmt="10.5f"):
        print (array.size*("{:"+fmt+"}")).format(*array)
    

    It's not difficult to modify it for multi-dimensional arrays.

提交回复
热议问题