你能帮我把西类牙语的 amount 转换成 word 吗? 我正在使用 num2word 库,但您可以看到一些小数点未正确转换。
>>> from num2words import num2words
>>> num2words(9036.20)
u'nine thousand and thirty-six point two zero'
>>> num2words(9036.21)
u'nine thousand and thirty-six point two zero'
>>> num2words(9036.55)
u'nine thousand and thirty-six point five four'
>>> num2words(9036.55, lang='es')
u'nueve mil treinta y seis punto cinco cuatro'
请分享您的宝贵经验。
最佳答案
顺便说一句:Stack Overflow 的西类牙语 is now in the public beta stage .
This is a known issue with num2word解决方案是使用 Decimal
并将浮点值转换为字符串
>>> from num2words import num2words
>>> from decimal import Decimal
>>> num2words(Decimal(str(9036.55)), lang='es')
>>> u'nueve mil treinta y seis punto cinco cinco'
关于python - 在 Python 中将金额转换为单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30689779/