How to convert amount to word in Indian?
我正在使用N2words 图书馆,但该图书馆在提出“ la”和“ores”。
例如:
num2words(903614.55, lang= en-IN )
Its printing nine hundred and three thousand, six hundred and fourteen point five five
但是,印度实际数额的列报方式应为:nine lakhs 3 000, 640 14 and five paisa
。
随后,我尝试了以下法典:
def num2words(num):
under_20 = [ Zero , One , Two , Three , Four , Five , Six , Seven , Eight , Nine , Ten , Eleven , Twelve , Thirteen , Fourteen , Fifteen , Sixteen , Seventeen , Eighteen , Nineteen ]
tens = [ Twenty , Thirty , Forty , Fifty , Sixty , Seventy , Eighty , Ninety ]
above_100 = {100: Hundred ,1000: Thousand , 100000: Lakhs , 10000000: Crores }
if num < 20:
return under_20[num]
if num < 100:
return tens[(int)(num/10)-2] + ( if num%10==0 else + under_20[num%10])
# find the appropriate pivot - Million in 3,603,550, or Thousand in 603,550
pivot = max([key for key in above_100.keys() if key <= num])
return num2words((int)(num/pivot)) + + above_100[pivot] + ( if num%pivot==0 else + num2words(num%pivot))
但现在出现错误
类型:清单指标必须是分类账或斜体,而不是小数。 Decimal
我的问题是人数少,Integer正在做罚款。