See the locale module.

This does currency (and date) formatting.

>>> import locale
>>> locale.setlocale( locale.LC_ALL, '' )
'English_United States.1252'
>>> locale.currency( 188518982.18 )
'$188518982.18'
>>> locale.currency( 188518982.18, grouping=True )
'$188,518,982.18'
Answer from S.Lott on Stack Overflow
Discussions

python - Converting Float to Dollars and Cents - Stack Overflow
First of all, I have tried this post (among others): Currency formatting in Python. It has no affect on my variable. My best guess is that it is because I am using Python 3 and that was code for ... More on stackoverflow.com
🌐 stackoverflow.com
how to handle Currency in python ?
Use f-strings or format with the precision specified. val = 10 print("{:.2f}".format(val)) print(f"{val:.2f}") Be aware that floats aren't always accurate . If you're displaying them, there should be no issues. but calculations involving currency might drift off after some time. More on reddit.com
🌐 r/learnpython
10
3
March 22, 2021
Adding $ or % in python without space in between the symbol and number.

You should look into pyformat when you only want to play around with the string representation.

>>> cash = 13.14
>>> '${}'.format(cash)
'$13.14'
>>> cash = 3.4
>>> '${:.2f}'.format(cash)
'$3.40'
>>> values = [1.2, 65.32, 15.2345]
>>> template = 'Stuff costs ${:.2f}.'
>>> for value in values:
        print(template.format(value))


Stuff costs $1.20.
Stuff costs $65.32.
Stuff costs $15.23.

You could also play around with object oriantation and manipulate the specific string manipulation:

>>> class Dollar:
        def __init__(self, value):
	        self.value = value
        def __add__(self, other):
	        return Dollar(self.value + other.value)
        def __sub__(self, other):
	        return Dollar(self.value - other.value)
        def __repr__(self):
	        return 'Dollar({})'.format(self.value)
        def __str__(self):
	        return '${:.2f}'.format(self.value)


>>> d1 = Dollar(1.2)
>>> d2 = Dollar(4.63)
>>> d1
Dollar(1.2)
>>> str(d1)
'$1.20'
>>> d2
Dollar(4.63)
>>> str(d2)
'$4.63'
>>> d1+d2
Dollar(5.83)
>>> d1-d2
Dollar(-3.4299999999999997)
>>> print(d1+d2)
$5.83
>>> print(d1-d2)
$-3.43
>>> price = Dollar(0.99)
>>> 'The price is {}'.format(price)
'The price is $0.99'

See, with this double underscore methods you can mess around with the power of python. __add__ let's you override the plus operator, __str__ controls the string conversion and __repr__ the internal interpreter representation.

Of course you should convert your values to Decimal compute with that to avoid aweful rounding errors:

>>> from decimal import Decimal
>>> str(Decimal('0.1'))
'0.1'
>>> class Dollar:
        def __init__(self, value):
	        self.value = Decimal(str(value))
        def __add__(self, other):
	        return Dollar(self.value + other.value)
        def __sub__(self, other):
	        return Dollar(self.value - other.value)
        def __repr__(self):
	        return 'Dollar({})'.format(self.value)
        def __str__(self):
	        return '${:.2f}'.format(self.value)


>>> d1 = Dollar(1.2)
>>> d2 = Dollar(4.63)
>>> d1
Dollar(1.2)
>>> str(d1)
'$1.20'
>>> d2
Dollar(4.63)
>>> str(d2)
'$4.63'
>>> d1+d2
Dollar(5.83)
>>> d1-d2
Dollar(-3.43)
>>> print(d1+d2)
$5.83
>>> print(d1-d2)
$-3.43
>>> price = Dollar(0.99)
>>> 'The price is {}'.format(price)
'The price is $0.99'

Do you see the difference? ;)

Also there is alot more, but for the beginning is that enough.

More on reddit.com
🌐 r/learnpython
10
22
February 12, 2016
How to format Currency without currency sign.
babel.numbers.format_number - the comma isn't specific to "currency format". More on reddit.com
🌐 r/learnpython
9
13
April 3, 2014
🌐
W3Schools
w3schools.com › python › python_string_formatting.asp
Python String Formatting
A modifier is included by adding a colon : followed by a legal formatting type, like .2f which means fixed point number with 2 decimals: ... You can perform Python operations inside the placeholders.
🌐
Stack Abuse
stackabuse.com › format-number-as-currency-string-in-python
How to Format Number as Currency String in Python
February 24, 2023 - In this tutorial, we'll cover how to format a number as a currency string in Python, using the built-in str.format() method, the locale module and the Babel module.
🌐
Pocoo
babel.pocoo.org › en › latest › api › numbers.html
Numbers and Currencies — Babel 2.17.0 documentation
The order of the number and currency name, along with the correct localized plural form of the currency name, is chosen according to locale: >>> format_currency(1, 'USD', locale='en_US', format_type='name') '1.00 US dollar' >>> format_currency(1099.98, 'USD', locale='en_US', format_type='name') ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-format-numbers-as-currency-strings-in-python
How to format numbers as currency strings in Python - GeeksforGeeks
July 23, 2025 - Formatting numbers as currency strings in Python involves presenting numeric values in the standardized currency format typically including the currency symbol, thousands separators and the number of the decimal places.
Find elsewhere
🌐
PyPI
pypi.org › project › format-currency
format-currency · PyPI
from format_currency import format_currency # format currency by country code, using the selected country's local monetary number formatting formatted = format_currency(1234567.89, 'US') # returns $ 1,234,567.89 formatted = format_currency(...
      » pip install format-currency
    
Published   Jul 27, 2024
Version   0.0.10
🌐
Replit
replit.com › home › discover › how to format a number as currency in python
How to format a number as currency in Python | Replit
The real power for currency formatting comes from the format specifier, which follows the colon inside the curly braces. In f"${amount:,.2f}", the specifier gives Python direct instructions on how to present the number.
🌐
Jerry Ng
jerrynsh.com › 3-useful-python-f-string-tricks-you-probably-dont-know
3 Useful Python F-string Tricks You Probably Don’t Know
August 3, 2021 - Read how to format float using f string in Python. Learn to format datetime, padding zero and white spaces using Python f string with examples.
🌐
Tutorialspoint
tutorialspoint.com › python › python_locale_currency_function.htm
Python locale.currency() Function
The Python locale.currency() function is used to format a given number as a currency string according to the locale settings. It allows displaying currency values with appropriate symbols, separators, and decimal formatting.
🌐
GitHub
github.com › arifwn › format-currency
GitHub - arifwn/format-currency: A no-frill currency formatting python library. · GitHub
... from format_currency import format_currency # Format currency by country code, using the selected country's local monetary number formatting formatted = format_currency(1234567.89, 'US') # returns $ 1,234,567.89 formatted = format_curre...
Starred by 2 users
Forked by 2 users
Languages   Python 98.8% | Shell 1.2%
🌐
Wikipedia
en.wikipedia.org › wiki › Dollar_sign
Dollar sign - Wikipedia
4 days ago - Other languages, including Java and Python, use it to mark the place where the result of an expression elsewhere should be inserted into text. $ is used for defining hexadecimal constants in some variants of assembly language (such as the Motorola 6800, Motorola 68000 and MOS Technology 6502 assembly languages), in Pascal and in Pascal-like languages such as Free Pascal and Delphi. $ is used in the ALGOL 68 language to delimit transput format ...
🌐
International Monetary Fund
imf.org › en › data
IMF Data
Welcome to the IMF data, including databases and platforms that have access to understandable and timely data, transforming lives by making economic and financial data findable, browsable, and usable.
🌐
VDCI
vdci.edu › formatting numbers with python: using apply and lambda
Formatting Numbers with Python: Using Apply and Lambda - Free Video Tutorial
May 4, 2025 - Format numeric values as currency strings with dollar signs and commas using a custom function or lambda with apply.
🌐
Python
docs.python.org › 3 › library › locale.html
locale — Internationalization services
Get the currency symbol, preceded by “-” if the symbol should appear before the value, “+” if the symbol should appear after the value, or “.” if the symbol should replace the radix character.
🌐
Substack
onepagecode.substack.com › p › engineering-alpha-a-systematic-fx
Engineering Alpha: A Systematic FX Carry Strategy Across Global Yield Curves
April 23, 2026 - Currency conversions use observed market mid rates. Positions and funding are rebalanced weekly. This section sets up the environment for the notebook. We import the Python packages required throughout the analysis, declare helper functions that will be referenced by later cells, and establish the global constants (written in uppercase) that govern the date range, notional amounts and other configuration choices used in the backtest.
🌐
PyFormat
pyformat.info
PyFormat: Using % and .format() for great good!
The new-style simple formatter calls by default the __format__() method of an object for its representation. If you just want to render the output of str(...) or repr(...) you can use the !s or !r conversion flags. In %-style you usually use %s for the string representation but there is %r for a repr(...) conversion. class Data(object): def __str__(self): return 'str' def __repr__(self): return 'repr' ... In Python 3 there exists an additional conversion flag that uses the output of repr(...) but uses ascii(...) instead.
🌐
Finnhub
finnhub.io › docs › api
API Documentation | Finnhub - Free APIs for realtime stock, forex, and cryptocurrency. Company fundamentals, economic data, and alternative data.
Finnhub - Free APIs for realtime stock, forex, and cryptocurrency. Company fundamentals, Economic data, and Alternative data.