Format Numbers as Currencies
A no-frill currency formatting library.
Table of Contents
Installation
pip install format-currency
Usage
from format_currency import format_currency
formatted = format_currency(1234567.89, 'US')
formatted = format_currency(1234567.89, 'ID')
formatted = format_currency(1234567.89, currency_code='USD')
formatted = format_currency(1234567.89, currency_code='IDR')
formatted = format_currency(value, country_code='CN', smart_number_formatting=True)
import locale
locale.setlocale(locale.LC_ALL, '')
formatted = format_currency(1234567.89, 'US', use_current_locale=True)
formatted = format_currency(1234567.89, 'ID', use_current_locale=True)
Testing
Install dependencies:
python -m pip install --upgrade pip build hatch
Run the test runner:
./test_runner.sh
License
format-currency
is distributed under the terms of the MIT license.
References