python format money code example
Example 1: format integer to be money python
formatted_float = "${:,.2f}".format(1500.2)
Example 2: python convert long floats to usd
def as_currency(amount):
if amount >= 0:
return '${:,.2f}'.format(amount)
else:
return '-${:,.2f}'.format(-amount)