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.
Metadata
Release files for moneyfmt 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| moneyfmt-1.0.3.tar.gz | 3.9 kB | Without provenance | Details |
Release files / moneyfmt-1.0.3.tar.gz
| Download URL | moneyfmt-1.0.3.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c0361d80b2791efe650782e51a55d67fc5cbde1c72eaecc4d8dbe0339975c19
|
|
BLAKE2b-256 checksum How to use checksums |
7230e998319412269ed17a895ae0ce0fc536f23fcf21fa5963fb1f352d0266b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for moneyfmt 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.