赞
踩
def toInt(value): isum = 0 nums = {'零': 0, '壹': 1, '贰':2, '叁': 3, '肆': 4, '伍': 5, '陆': 6, '柒': 7, '捌': 8, '玖':9} dw = {'拾': 3, '元': 2, '佰': 4, '仟': 5, '万' : 6, '角': 1, '分': 0} index = 0 while index < len(value): if value[index] != '零': if (value[index] == '拾'): isum += 1000; index += 1 elif value[index] in nums : isum += nums[value[index]] * pow(10, dw[value[index + 1]]) index += 2 else: index +=1 else: index += 1 return round(isum, 2) / 100
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。