2

I'm trying to parse a near 0 number using the decimal.Decimal python module:

>>> import decimal
>>> from decimal import Decimal
>>> Decimal("0.00000161")
Decimal('0.00000161')
>>> Decimal("0.00000061")
Decimal('6.1E-7')
>>> 

What would be the best way to print "0.00000061" instead of "6.1E-7"?

Marcin
  • 48,559
  • 18
  • 128
  • 201
n00bz0r
  • 87
  • 9

2 Answers2

6
In [157]: from decimal import Decimal

In [158]: x = Decimal("0.00000061")

In [159]: format(x, 'f')
Out[159]: '0.00000061'
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
4
from decimal import Decimal
x = Decimal('0.00000061')
print '{0:f}'.format(x)
khelwood
  • 55,782
  • 14
  • 81
  • 108