Advertisement
Guest User

fgfgf

a guest
Aug 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. def decimal2text(value, places=2,
  2.  
  3. int_units=((u'рубль', u'рубля', u'рублей'), 'm'),
  4.  
  5. exp_units=(('', '', ''), 'm')):
  6.  
  7. value = decimal.Decimal(value)
  8.  
  9. q = decimal.Decimal(10) ** -places
  10.  
  11.  
  12.  
  13. integral, exp = str(value.quantize(q)).split('.')
  14.  
  15. mystr = u'{};{}'.format(
  16.  
  17. num2text(int(integral), int_units),
  18.  
  19. num2text(int(exp), exp_units))
  20. return (u'{} {}'.format(str(int(integral))[:-3],str(int(integral))[-3:])+" ("+(mystr.split(";")[0])+") "+str(int(exp))+u" коп.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement