python - 如何让 numpy 不以科学记数法打印

标签 python numpy

<分区>

这是一个非常简单的问题,但我不知道用正确的词来谷歌。我有一个 numpy 数组:

A = np.array([ 8.1588e-01, -3.9675e-04])

我想把它打印成普通的十进制数字。即 0.81588, -0.00039675

你怎么做到的?

最佳答案

Numpy 让您可以使用 set_printoptions 全局自定义输出.

要摆脱科学记数法,您可以使用:

 np.set_printoptions(suppress=True) # don't use scientific notation

来自文档:

suppress : bool, optional

If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero. If False, then scientific notation is used when absolute value of the smallest number is < 1e-4 or the ratio of the maximum absolute value to the minimum is > 1e3. The default is False.

关于python - 如何让 numpy 不以科学记数法打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50771966/

相关文章:

python - 如何判断两个字符串是否有共同的字符部分?--Python

python - 使用 sklearn.cluster Kmeans 时出现内存错误

performance - 创建一维 NumPy 数组的 NoN 填充元素的滑动窗口

Python pandas 数据框平均值和绘图值

python - 将两个 collections.Counter() 对象的内容相加

python - Python中的raw_input函数

python - 如何在python plotly dash中使用Font Awesome图标

numpy - 用相同的数字填充一个 numpy 数组?

numpy - 优化 Python KD 树搜索

python - 提取 numpy 3D 数组