def char2num(s): return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '.': 10}[s] def dotpositon(s): return len(s) - [i for i, t in enumerate(s) if t == '.'][0] - 1 def num2float(x, y): if y == 10: return x else: return x*10+y return reduce(num2float, map(char2num, s))/(10**dotpositon(s))
Sign in to make a reply
童鞋昵称能改吧