from functools import reducedef str2float(s): s1=s.split('.')[0] s2=s.split('.')[-1] Ls1=list(map(int,list(s1))) Ls2=list(map(int,list(s2))) def str2num(x,y): return x10+y return float(reduce(str2num,Ls1))+float(reduce(str2num,Ls2))(10**(-len(Ls2)))
Sign in to make a reply
进击的数据分析小菜鸟
from functools import reduce
def str2float(s): s1=s.split('.')[0] s2=s.split('.')[-1] Ls1=list(map(int,list(s1))) Ls2=list(map(int,list(s2))) def str2num(x,y): return x10+y return float(reduce(str2num,Ls1))+float(reduce(str2num,Ls2))(10**(-len(Ls2)))