Closed nsrshishir closed 1 year ago
You can do something like this using https://pypi.org/project/inflect/
import math
import inflect # pip install inflect
value = 78568.1257
p = inflect.engine()
cents, dollars = math.modf(value)
dollars = p.number_to_words(round(dollars))
cents = p.number_to_words(round(cents * 100))
print(f"{dollars} dollars and {cents} cents")
seventy-eight thousand, five hundred and sixty-eight dollars and thirteen cents
Thanks Python-Humanize/Humanize. Appreciate it.
Best Regards, Md. Niaj Shahriar Shishir Software Engineer and Server Specialist, Metamorphosis Ltd, Dhaka, Bangladesh. Cell: 01827512928
On Tue, Aug 1, 2023, 4:46 PM Hugo van Kemenade @.***> wrote:
You can do something like this using https://pypi.org/project/inflect/
import math import inflect # pip install inflect value = 78568.1257p = inflect.engine() cents, dollars = math.modf(value) dollars = p.number_to_words(round(dollars))cents = p.number_to_words(round(cents * 100)) print(f"{dollars} dollars and {cents} cents")
seventy-eight thousand, five hundred and sixty-eight dollars and thirteen cents
— Reply to this email directly, view it on GitHub https://github.com/python-humanize/humanize/issues/132#issuecomment-1660056170, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARQHARHH37JFDLW7KQGJ5MTXTDM6VANCNFSM6AAAAAA2PWB4KQ . You are receiving this because you authored the thread.Message ID: @.***>
What did you do?
Wanted to print the Sale order total say "78568.1257" in Human readable string.
What did you expect to happen?
output like "Seventy eight thousand five hundred sixty eight dollar and thirteen cents"
What actually happened?
78.57 thousand
What versions are you using?
4.7.0