Converte tipo Decimal para uma string formatda como dinheiro.
Project description
Moneyfmt
Converte tipo Decimal para uma string formatada como dinheiro
Como usar
Instale com:
pip install moneyfmt
Use no seu código:
from moneyfmt import moneyfmt
Parâmetros
places: required number of places after the decimal point
curr: optional currency symbol before the sign (may be blank)
sep: optional grouping separator (comma, period, space, or blank)
dp: decimal point indicator (comma or period)
only specify as blank when places is zero
pos: optional sign for positive numbers: '+', space or blank
neg: optional sign for negative numbers: '-', '(', space or blank
trailneg:optional trailing minus indicator: '-', ')', space or blank
Como usar?
from moneyfmt import moneyfmt
>>> d = Decimal('-1234567.8901')
>>> moneyfmt(d, curr='$')
'-$1,234,567.89'
>>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')
'1.234.568-'
>>> moneyfmt(d, curr='$', neg='(', trailneg=')')
'($1,234,567.89)'
>>> moneyfmt(Decimal(123456789), sep=' ')
'123 456 789.00'
>>> moneyfmt(Decimal('-0.02'), neg='<',
>>> trailneg='>')
'<0.02>'
Referência: https://docs.python.org/3/library/decimal.html
Licença
Leia https://docs.python.org/pt-br/3.7/copyright.html
Copyright © 2001-2021 Python Software Foundation. All rights reserved.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
moneyfmt-1.0.3.tar.gz
(3.9 kB
view details)
File details
Details for the file moneyfmt-1.0.3.tar.gz
.
File metadata
- Download URL: moneyfmt-1.0.3.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c0361d80b2791efe650782e51a55d67fc5cbde1c72eaecc4d8dbe0339975c19 |
|
MD5 | 80ef0a5bc01af6f5524ee286d560f107 |
|
BLAKE2b-256 | 7230e998319412269ed17a895ae0ce0fc536f23fcf21fa5963fb1f352d0266b3 |