def str2float(s):
n = 0
result = []
for i in range(0, len(s)):
if s[i] == '.':
n = i
else:
result.append(s[i])
return reduce(lambda x, y:x * 10 + y, list(map(lambda x:float(x), result))) * pow(10, -n)
Sign in to make a reply
冯先生Stefan
def str2float(s):
n = 0
result = []
for i in range(0, len(s)):
if s[i] == '.':
n = i
else:
result.append(s[i])
return reduce(lambda x, y:x * 10 + y, list(map(lambda x:float(x), result))) * pow(10, -n)