def str2float(s): def char2num(s): digitals = {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9} return digitals[s] index = s.index('.') s1 = s[:index] s2 = s[index+1:] f = lambda x,y: x*10+y return reduce(f,map(char2num, s1)) + reduce(f,map(char2num, s2))/(10**len(s2))
Sign in to make a reply
带刺的黄瓜666