# -*- coding: utf-8 -*-
from functools import reduce
def str2float(s):
def fnzs(x,y):
return x*10+y;
n = s.index('.');
s1 = list(map(int,s[:n]));
s2 = list(map(int,s[n+1:]));
return reduce(fnzs,s1)+reduce(fnzs,s2)/pow(10,len(s2));
print('str2float(\'123.456\') =', str2float('123.456'))
if abs(str2float('123.456') - 123.456) < 0.00001:
print('测试成功!')
else:
print('测试失败!')