Skip to main content

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

# smart formatting
formatted = format_currency(value, country_code='CN', smart_number_formatting=True) # returns ¥ 123.46 万

# 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

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.10.tar.gz (169.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

format_currency-0.0.10-py3-none-any.whl (167.9 kB view details)

Uploaded Python 3

File details

Details for the file format_currency-0.0.10.tar.gz.

File metadata

  • Download URL: format_currency-0.0.10.tar.gz
  • Upload date:
  • Size: 169.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for format_currency-0.0.10.tar.gz
Algorithm Hash digest
SHA256 15f01e5aaecf7c636815911cf0cbab0b117c8a6bd992d61a666f5e038cce32d9
MD5 f90dbda70792d7b12fa12762fbc0ddd9
BLAKE2b-256 3d18ee5527f52565bd79f3111e7fac7fbfe384f5b9bf909431814c2dc0457815

See more details on using hashes here.

File details

Details for the file format_currency-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for format_currency-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 eedecf0b2c4d21b2435eff3eed95658160d0602c444f921dd22ce4bfab7735c7
MD5 87c137348a5d10a4fc9f00acb2b02412
BLAKE2b-256 94cb788941330c524422c87583121b0d589636a982fad0685f9f3b7c7588c2f4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page