Python Lowercase to uppercase amount
Excerpt from: http://shine-it.net/index.php?topic=14575.0
def_rmb_upper (self, value):"""RMB capitalization from: http://topic.csdn.net/u/20091129/20/b778a93d-9f8f-4829-9297-d05b08a23f80.html The value of the incoming floating-point type is returned Back to Unicode string"""Map= [u"0", u" One", u"Ii.", u"three", u"Restaurant", u"Wu", u"Lu", u"Qi", u"BA", u"JIU"] Unit= [u"points", u"Angle", u"Yuan", u"Pick", u"Hundred", u"thousand", u"million", u"Pick", u"Hundred", u"thousand", u"billion", U"Pick", u"Hundred", u"thousand", u"million", u"Pick", u"Hundred", u"thousand", u"trillion"] Nums= []#take out each digit, integer convert the error of avoiding large number by character mode forIinchRange (Len (unit)-3,-3, 1): ifValue >= 10**iorI < 1: nums.append (int (round (value/(10**i), 2))%10) Words=[] Zflag= 0#Mark 0 consecutive times to delete the word, or insert 0 words in a timely mannerstart = Len (nums)-3 forIinchRange (Start,-3,-1):#make I correspond to the actual number of digits, negative numbers are the angular points if0! = Nums[start-i]orLen (words) = =0:ifzflag:words.append (map[0]) Zflag=0 words.append (Map[nums[start-i]]) words.append (unit[i+2]) elif0 = = Ior(0 = = i%4 andZflag < 3):#control ' million/Yuan 'Words.append (unit[i+2]) Zflag=0Else: Zflag+ = 1ifWORDS[-1]! = Unit[0]:#End non-' sub ' complement wordWords.append (U"Whole") return "'. Join (words)
Python Lowercase to uppercase amount