A no-frill currency formatting library.
Project description
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
# 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(1234567.89, 'ID') # returns Rp 1.234.567,89
#format currency by currency code
formatted = format_currency(1234567.89, currency_code='USD') # returns $ 1,234,567.89
formatted = format_currency(1234567.89, currency_code='IDR') # returns Rp 1.234.567,89
# format currency by country code, respecting global locale settings
import locale
locale.setlocale(locale.LC_ALL, '')
formatted = format_currency(1234567.89, 'US', use_current_locale=True) # returns $ 1,234,567.89
formatted = format_currency(1234567.89, 'ID', use_current_locale=True) # returns Rp 1,234,567.89
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
format_currency-0.0.6.tar.gz
(167.2 kB
view hashes)
Built Distribution
Close
Hashes for format_currency-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0c25279b351581ba862c54f6c19cc88bfaecbd7646fe57c675152446b07cda2 |
|
MD5 | efc09bc93d818590a99ac54220c57319 |
|
BLAKE2b-256 | 95faa60b21477476c47bd98d80d063131cef53b5824e6feaed0515ae3110b9f6 |