def str2float(s: str): # 字符串转浮点数
def fn(n,m): return n*10 + m
def chrto(i): return ord(i) - ord('0');
def xfn(n,m): return n/10 + m;
def xchrto(i): return (ord(i) - ord('0'))/10;
sary = s.split('.')
return reduce(fn, map(chrto, sary[0])) + (0 if len(sary)==1 else reduce(xfn, map(xchrto, reversed(sary[1]))));
Sign in to make a reply
广州dw
def str2float(s: str): # 字符串转浮点数
def fn(n,m): return n*10 + m
def chrto(i): return ord(i) - ord('0');
def xfn(n,m): return n/10 + m;
def xchrto(i): return (ord(i) - ord('0'))/10;
sary = s.split('.')
return reduce(fn, map(chrto, sary[0])) + (0 if len(sary)==1 else reduce(xfn, map(xchrto, reversed(sary[1]))));