DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} a='' n=0 for i in range(len(s)): if s[i]=='.': n=len(s)-1-i else: a=a+s[i] def char2num(s): return DIGITS[s] result = reduce(lambda x, y: x * 10 + y, map(char2num, a)) return result/(10**n)
Sign in to make a reply
____橡皮____