I assume that you have a list, not an array, but here it does not really matter; in version 2.6 and earlier versions of Python, something like:
>>> L = [2.32313e+07, 2.1155e+07, 1.923e+07, 11856, 112.32] >>> for x in L: print '%f' % x ... 23231300.000000 21155000.000000 19230000.000000 11856.000000 112.320000
and in version 2.6 or later, .format . I suppose you know that numbers as such, like numbers, are not in any "format" - these are the strings you get by formatting the numbers, for example. for output that are in some format. BTW, options on this %f can let you control the number of decimal places, width, alignment, etc. - Itβs hard to offer exactly what you might want, without additional specifications from you.
In awk you can use printf .
Alex martelli
source share