1 dictnum ={'零':0,'一':1,'二':2,'三':3,'四':4,'五':5,'六':6,'七':7,'八':8,'九':9,'十':10,'百':12,'千':13,'万':14,'亿':18,'两':2, 2 '壹':1,'贰':2,'叁':3,'肆':4,'伍':5,'陆':6,'柒':7,'捌':8,'玖':9,'拾':10,'佰':12} 3 def getResultForDigit(a): 4 count = len(a)-1 5 result = 0 6 tmp = 0 7 8 while count >= 0: 9 tmpChr = a[count:count+1] 10 tmpNum = 0 11 if tmpChr.isdigit():#防止大写数字中夹杂阿拉伯字母 12 tmpNum=int(tmpChr) 13 else: 14 tmpNum = dictnum[tmpChr] 15 if tmpNum >10:#获取0的个数 16 tmp=tmpNum-10 17 #如果是个位数 18 else: 19 if tmp == 0: 20 result+=tmpNum 21 else: 22 result+=pow(10,tmp)*tmpNum 23 tmp = tmp+1 24 count = count - 1 25 return result