https://github.com/nearhuscarl/py-currency
A python library to convert currency, prettify price and get various currency info
https://github.com/nearhuscarl/py-currency
currency currency-converter money
Last synced: about 2 months ago
JSON representation
A python library to convert currency, prettify price and get various currency info
- Host: GitHub
- URL: https://github.com/nearhuscarl/py-currency
- Owner: NearHuscarl
- License: bsd-3-clause
- Created: 2018-02-16T22:02:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-04T16:42:58.000Z (over 7 years ago)
- Last Synced: 2025-07-15T23:56:48.148Z (3 months ago)
- Topics: currency, currency-converter, money
- Language: Python
- Size: 16.6 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.md
Awesome Lists containing this project
README
Py Currency
===========Version: 1.0.2
A simple currency module to:
* Retrieve various info about currency
* Format currency price
* Convert between currenciesRequirements
------------* python3
* Internet connection (optional)Installation
------------.. code:: bash
$ pip install nh-currency
Usage
-----.. code:: python
import currency
Get currency name
^^^^^^^^^^^^^^^^^.. code:: python
currency.name('USD')
currency.name('USD', plural=True).. code:: python
'US Dollar'
'US dollars'Symbol
^^^^^^.. code:: python
currency.symbol('CAD')
currency.symbol('CAD', native=False)
currency.symbol('NOK')
currency.symbol('NOK', native=False).. code:: python
'$'
'CA$'
'kr'
'Nkr'Number of decimal digits
^^^^^^^^^^^^^^^^^^^^^^^^.. code:: python
currency.decimals('USD')
currency.decimals('JPY').. code:: python
2
0Round to the maximum decimal digits
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.. code:: python
currency.rounding(100.115735, 'USD')
currency.rounding(2253.12309, 'ISK').. code:: python
100.12
2253Currency increment used for rounding
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.. code:: python
currency.roundto('USD')
currency.roundto('CHF').. code:: python
0
0.05Format currency
^^^^^^^^^^^^^^^.. code:: python
currency.pretty(10050000.2394, 'USD')
currency.pretty(10050000.2394, 'USD', trim=True)
currency.pretty(10050000.2394, 'USD', abbrev=False).. code:: python
'$10,050,000.2394'
'$10,050,000.24'
'10,050,000.2394 USD'Convert to other currency
^^^^^^^^^^^^^^^^^^^^^^^^^.. code:: python
currency.convert('USD', 'EUR')
currency.convert('USD', 'EUR', 2)
currency.convert('JPY', 'AUD', 100).. code:: python
0.815797
1.631594
1.1759Currency info
^^^^^^^^^^^^^.. code:: python
currency.info('USD')
.. code:: python
# 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
-------.. code:: bash
$ cd .../py-currency
$ python -m unittestRelated Work
------------`coinify `__
Resources
---------https://gist.github.com/Fluidbyte/2973986
https://www.wikipedia.org/