How to suppress scientific notation when printing float values?

后端 未结 12 1278
猫巷女王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:56

    Using 3.6.4, I was having a similar problem that randomly, a number in the output file would be formatted with scientific notation when using this:

    fout.write('someFloats: {0:0.8},{1:0.8},{2:0.8}'.format(someFloat[0], someFloat[1], someFloat[2]))
    

    All that I had to do to fix it was to add 'f':

    fout.write('someFloats: {0:0.8f},{1:0.8f},{2:0.8f}'.format(someFloat[0], someFloat[1], someFloat[2]))
    

提交回复
热议问题