from functools import reduce def str2float(s): def turn(a): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'.':'.'}[a] def time(max): k=1 a=1 while k<=max: k=k+1 a=a*10 return a n=0 while n<len(list(map(turn,s))): n=n+1 if list(map(turn,s))[n-1]=='.': break L=list(map(turn,s)) L.pop(n-1) n=len(L)-n+1 return reduce(lambda x,y:10*x+y,L)/time(n)
Sign in to make a reply
方遒挥斥之