convert exponential to decimal in python

后端 未结 3 1468
你的背包
你的背包 2021-01-12 22:40

I have an array in python that contains a set of values, some of them are

2.32313e+07

2.1155e+07

1.923e+07

11856

112.32

How d

3条回答
  •  一生所求
    2021-01-12 23:13

    You can use locale.format() to format your numbers for output. This has the additional benefit of being consistent with any locale-specific conventions that might be expected in the presentation of the numbers. If you want complete control at the specific place where you do the output, you'd be better of with the print "format" % vars... variant.

    Example:

    >>> import locale 
    >>> locale.setlocale(locale.LC_ALL, "")
    'C/UTF-8/C/C/C/C'
    >>> locale.format("%f", 2.32313e+07, 1)
    '23231300.000000'
    

提交回复
热议问题