Convert Scientific Notation to Float

邮差的信 提交于 2019-11-30 10:50:48

You are looking at the default str() formatting of floating point numbers, where scientific notation is used for sufficiently small or large numbers.

You don't need to convert this, the value itself is a proper float. If you need to display this in a different format, format it explicitly:

>>> print 0.00001357
1.357e-05
>>> print format(0.00001357, 'f')
0.000014
>>> print format(0.00001357, '.8f')
0.00001357

Here the f format always uses fixed point notation for the value. The default precision is 6 digits; the .8 instructs the f formatter to show 8 digits instead.

The default string format is essentially the same as format(fpvalue, '.12g'); the g format uses either a scientific or fixed point presentation depending on the exponent of the number.

You can use print formatting:

x = 1.357e-05    
print('%f' % x)

Edit:

print('%.08f' % x)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!