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 OverflowJerry 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 - Format float type variable as a pretty-looking currency. Simple! Besides using it to format float type variables, we can even use f-string along with datetime type variable.
Videos
08:07
Python Tutorial #9: Formatting output with fstrings 🐍 - YouTube
08:20
How to Use f-Strings (Formatted Strings) in Python - YouTube
19:43
Every F-String Trick In Python Explained - YouTube
11:16
Python F-Strings: Advanced Tips and Tricks - YouTube
F-Strings Have A Lot of Format Modifiers You Don't Know
05:14
Fstrings & Math - Python for Beginners - YouTube
Top answer 1 of 16
290
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'
2 of 16
115
New in 2.7
>>> '{:20,.2f}'.format(18446744073709551616.0)
'18,446,744,073,709,551,616.00'
http://docs.python.org/dev/whatsnew/2.7.html#pep-0378
W3Schools
w3schools.com › python › python_string_formatting.asp
Python String Formatting
Before Python 3.6 we had to use the format() method. F-string allows you to format selected parts of a string.
Real Python
realpython.com › how-to-python-f-string-format-float
How to Format Floats Within F-Strings in Python – Real Python
April 24, 2024 - Note: When you define a format using the form ".2e", you are using a similar, but not identical, formatting language to the language used by the more modern format specifiers. This time, you are using old-style printf-style string formatting. If you want to display currencies, you can use the locale.currency() function:
DNMTechs
dnmtechs.com › currency-formatting-in-python-3-simplified-guide
Currency Formatting in Python 3: Simplified Guide – DNMTechs – Sharing and Storing Technology Knowledge
This will output the formatted currency value as “$1,234.56”. The “:,.2f” specifier inside the f-string formats the value as a float with two decimal places and comma as the thousands separator. In this simplified guide, we explored different methods to format currency values in Python 3.
ZetCode
zetcode.com › python › fstring
Python f-string - formatting strings in Python with f-string
May 11, 2025 - Beyond basic formatting, f-strings enable advanced operations such as inline calculations, function calls, and even conditional expressions. This versatility makes them suitable for a wide range of applications in Python development, from constructing log messages to formatting financial data.
Python Guides
pythonguides.com › format-decimal-places-in-python-using-f-strings
How To Format Decimal Places In Python Using F-Strings?
March 19, 2025 - As a developer working on numerous projects across the USA, I recently faced an issue where I needed to format currency values with a specific number of decimal places for our financial reports. After researching various string formatting techniques, I found that using f-strings is an efficient and readable way to format decimal places. I will help you learn how to format decimal places in Python using f-strings in this tutorial with examples.
AskPython
askpython.com › home › fixed digits after decimal with f-string
Fixed digits after decimal with F-string - AskPython
May 31, 2023 - Let’s see the example to understand the working of the f-string model. ... In this syntax, the value contains the number with a decimal point. After ‘.’, we need to define the number of fixed digits we want to print after the decimal point, followed by the ‘f’ letter. Value = 'Askpython' print(f"you can learn Python from {Value}.com")
Stack Abuse
stackabuse.com › format-number-as-currency-string-in-python
How to Format Number as Currency String in Python
February 24, 2023 - number_string = 340020.8 # This portion is responsible for grouping the number number_commas_only = "{:,}".format(number_string) print(number_commas_only) # To ensure we have two decimal places number_two_decimal = "{:.2f}".format(number_string) print(number_two_decimal) # Both combined along with the currency symbol(in this case $) currency_string = "${:,.2f}".format(number_string) print(currency_string) Running the code above we get the following output: ... Though, this approach is hard-coded, unlike the previous one, which you can use to localize the formatting dynamically. Using Babel is perhaps one of the lesser known methods, however it's very user-friendly and intuitive. It comes with number and currency formatting as well as other internationalizing tasks. Unlike Python's locale module, you don't have to worry about making adjustments on a global scale.
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-format-number-with-separator-for-thousands-and-currency
How to Format Numbers with Thousands Separators and Currency in Python | Tutorial Reference
This guide explores various methods in Python to format numbers with thousands separators and as currency, using f-strings, str.format(), and the locale module.
PyPI
pypi.org › project › multicurrency
multicurrency · PyPI
March 26, 2021 - # Using the `f-string` method >>> from multicurrency import Euro >>> euro = Euro(1000000*(1/7)) >>> f'{euro:4%a}' '142.857,1429' Some more examples of the Currency formatting feature usage (using the f-string method):
» pip install multicurrency
Version 2.1.0
Repository https://github.com/fscm/multicurrency