Home > Python > Format Python Decimal

Format Python Decimal

September 2nd, 2008 Leave a comment Go to comments

This shows you how to take a Python Deciaml type number and format it so that it shows up with two places after the decimal place (like dollar values).

>>> num = Decimal("5")
>>> num.quantize(decimal.Decimal('.01'))

Categories: Python Tags:
  1. No comments yet.
  1. No trackbacks yet.