def str2float(s): p = s.find('.'); l1 = s[:p] l2 = s[p+1:] return reduce(lambda x,y:x10+y,map(char2num,l1+l2)) pow(.1,len(l2))
def char2num(s): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,}[s]
Sign in to make a reply
hello_spring_cc
def str2float(s): p = s.find('.'); l1 = s[:p] l2 = s[p+1:] return reduce(lambda x,y:x10+y,map(char2num,l1+l2)) pow(.1,len(l2))
def char2num(s): return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,}[s]