def str2float(s): i=s.index(".") dicts={'0':0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9} new_s=s[:i]+s[(i+1):] def d(x): return dicts[x] def num(x,y): return x*10+y return reduce(num,map(d,new_s))/(10**(len(s)-i-1))
想问个问题,为什么要定义这个dicts,它的作用是什么?
Sign in to make a reply
静谧_聒噪_心