#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from functools import reduce
def str2float(s):
if not isinstance(s, str):
raise TypeError('bad operand type. Here str is expected.')
for i in range(len(s)):
if s[i] == '.':
break
L1 = [c for i1, c in enumerate(list(s)) if i1 < i]
L2 = [c for i2, c in enumerate(list(s)) if i2 > i]
L2.reverse()
L2.append(0)
res = reduce(lambda x,y: x*10+y, map(int, L1))
res = res + reduce(lambda x,y: x/10+y, map(int, L2))
return res
秋雨mac