A python library to convert currency, prettify price and get various currency info
Project description
A simple currency module to:
Retrive various info about currency
Format currency price
Convert between currencies
Requirements
python3
Internet connection (optional)
Installation
$ pip install py-currency
Usage
import currency
Get currency name
currency.name('USD')
currency.name('USD', plural=True)
'US Dollar'
'US dollars'
Symbol
currency.symbol('CAD')
currency.symbol('CAD', native=False)
currency.symbol('NOK')
currency.symbol('NOK', native=False)
'$'
'CA$'
'kr'
'Nkr'
Number of decimal digits
currency.decimals('USD')
currency.decimals('JPY')
2
0
Round to the maximum decimal digits
currency.rounding(100.115735, 'USD')
currency.rounding(2253.12309, 'ISK')
100.12
2253
Currency increment used for rounding
currency.roundto('USD')
currency.roundto('CHF')
0
0.05
Format currency
currency.pretty(10050000.2394, 'USD')
currency.pretty(10050000.2394, 'USD', trim=True)
currency.pretty(10050000.2394, 'USD', abbrev=False)
'$10,050,000.2394'
'$10,050,000.24'
'10,050,000.2394 USD'
Convert to other currency
currency.convert('USD', 'EUR')
currency.convert('USD', 'EUR', 2)
currency.convert('JPY', 'AUD', 100)
0.815797
1.631594
1.1759
Currency info
currency.info('USD')
# Output has been formatted for representation purpose
{
'symbol': '$',
'name': 'US Dollar',
'symbol_native': '$',
'decimal_digits': 2,
'rounding': 0,
'code': 'USD',
'name_plural': 'US dollars'
}
Testing
$ cd .../py-currency
$ python -m unittest
Resources
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
nh-currency-1.0.0.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for nh_currency-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4166f50e78f947d0437d01e26d6a122bc82bd3b3f5ab2d5dab813c008a58960f |
|
MD5 | 3bff42ae4c69ff2f28d297123391bcd6 |
|
BLAKE2b-256 | 77427e28ce38be9e2d5f7a1cb241dba40f0133fcf5f1bfdef8b99c8812541b96 |