python 更改数字格式 ndarray 许多位

标签 python numpy string-formatting multidimensional-array

我是Python初学者,很容易陷入困境和困惑......

当我读取一个包含带有数字的表格的文件时,它将其读取为 numpy.ndarray

Python 正在更改数字的显示。 例如: 在输入文件中我有这个号码:56143.0254154 在输出文件中,数字写为:5.61430254e+04

但我想在输出文件中保留第一种格式。 我尝试使用 string.format 或 locale.format 函数,但它不起作用

有人可以帮我做到这一点吗?

谢谢! 鲁西

最佳答案

尝试numpy.set_printoptions()——在那里你可以例如指定打印的位数并抑制科学记数法。例如,numpy.set_printoptions( precision=8,suppress=True) 将打印 8 位数字,并且不打印“...e+xx”。

关于python 更改数字格式 ndarray 许多位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14733471/

相关文章:

python - Dask 延迟性能问题

python - 使用 pycrypto (RSA) 签名和验证数据

python - 将 numpy 数组传递给 C++

python - 索引错误 : too many indices for np. 数组

python - 尝试使用 string.format() 将 unicode 字符打印到控制台

cocoa - 如何格式化/着色 NSTextView 字符串的技术

python - 使用Python打印出字符、单词和行的数量

python - 像 spyder 那样打包一个 python 应用程序

python - numpy代码中的溢出错误

swift - NumberFormatter() - 可以用特定数量的空格填充吗?