[def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
def fn(x, y): return x*10+y def char2num(s): return DIGITS[s] n = len(s)-1-s.find('.') s = s.replace('.','') return reduce(fn, map(char2num, s))/10**n]
Sign in to make a reply
子鱼若鱼
[def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}