Answers for "format number to dollar python 3 site:stackoverflow.com"

0

python convert long floats to usd

>>> '${:,.2f}'.format(1234.5)
'$1,234.50'
Posted by: Guest on November-09-2020
0

python convert long floats to usd

def as_currency(amount):
    if amount >= 0:
        return '${:,.2f}'.format(amount)
    else:
        return '-${:,.2f}'.format(-amount)
Posted by: Guest on November-09-2020

Code answers related to "format number to dollar python 3 site:stackoverflow.com"

Python Answers by Framework

Browse Popular Code Answers by Language