其他分享
首页 > 其他分享> > numpy 指定浮点数的小数位数

numpy 指定浮点数的小数位数

作者:互联网

问题来源

        做GUI的时候发现数据太长了,显示出来不好看,所以有这个需求

       

numpy.around函数

原型

numpy.around(a, decimals=0, out=None)

参数

返回值

示例

>>> np.around([1.23,4.56,7.89])
array([1.,4.,7])
>>> np.around([1.23,4.56,7.89], decimals=1)
array([1.2,4.6,7.9])
>>> np.around([1.23,4.56,7.89], decimals=2)
array([1.23,4.56,7.89])

标签:around,numpy,浮点数,7.89,np,小数位,array,4.56,decimals
来源: https://www.cnblogs.com/2944014083-zhiyu/p/14856136.html