def str2float(s): new_s=s.replace('.','') def str2int(new_s): return DIGIT[new_s] new_s=map(str2int,new_s) def fn(x,y): return x10+y f=reduce(fn,new_s) t=10*(len(s)-s.index('.')-1) return f/t
这是一个相对能看懂的,然后自己尝试了一下
Sign in to make a reply
走庄子路线
def str2float(s): new_s=s.replace('.','') def str2int(new_s): return DIGIT[new_s] new_s=map(str2int,new_s) def fn(x,y): return x10+y f=reduce(fn,new_s) t=10*(len(s)-s.index('.')-1) return f/t