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
  • 46,667
  • 17
  • 117
  • 197
n00bz0r
  • 77
  • 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
  • 777,569
  • 165
  • 1,697
  • 1,613
4
from decimal import Decimal
x = Decimal('0.00000061')
print '{0:f}'.format(x)
khelwood
  • 52,115
  • 13
  • 74
  • 94