How to suppress scientific notation when printing float values?

后端 未结 12 1463
猫巷女王i
猫巷女王i 2020-11-22 07:12

Here\'s my code:

x = 1.0
y = 100000.0    
print x/y

My quotient displays as 1.00000e-05.

Is there any way to suppress

12条回答
  •  面向向阳花
    2020-11-22 07:35

    '%f' % (x/y)
    

    but you need to manage precision yourself. e.g.,

    '%f' % (1/10**8)
    

    will display zeros only.
    details are in the docs

    Or for Python 3 the equivalent old formatting or the newer style formatting

提交回复
热议问题