def str2float(s):
c = ""
for i in range(-1, -len(s) - 1, -1):
if s[i] == '.':
pos = i + 1
continue
c = s[i] + c
def char2name(s):
return DIGITS[s]
return reduce(lambda x, y: x * 10 + y, map(char2name, c)) * pow(10, pos)
Sign in to make a reply
zicozicozi
def str2float(s):
c = ""
for i in range(-1, -len(s) - 1, -1):
if s[i] == '.':
pos = i + 1
continue
c = s[i] + c
def char2name(s):
return DIGITS[s]
return reduce(lambda x, y: x * 10 + y, map(char2name, c)) * pow(10, pos)