# -*- coding: utf-8 -*- from functools import reduce import math def str2float(s): def char2num(c): return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[c] def str2int(x, y): return 10*x + y index = len(s) - s.index('.') - 1 ss = s.replace('.', '') return reduce(str2int, map(char2num, ss))/math.pow(10, index)
Sign in to make a reply
Othershe