from functools import reduce digits = {'.': '.','0': 0,'1': 1,'2': 2,'3': 3,'4': 4,'5': 5, '6': 6,'7': 7,'8': 8,'9': 9}
def str2float(s): i = s.index('.') s = s.split('.') s = s[0] + s[1] def str1digit(x): return digits[x] def fun1(x, y):
return x * 10 + y return reduce(fun1, map(str1digit, s)) * 0.1 ** i
Sign in to make a reply
_盛盛_
from functools import reduce digits = {'.': '.','0': 0,'1': 1,'2': 2,'3': 3,'4': 4,'5': 5, '6': 6,'7': 7,'8': 8,'9': 9}
def str2float(s): i = s.index('.') s = s.split('.') s = s[0] + s[1] def str1digit(x): return digits[x] def fun1(x, y):