# -*- coding: utf-8 -*- from functools import reduce def str2float(s): dict = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} dec_list = s.split('.') dec_list[0] = reduce(lambda x, y: x * 10 + y, map(lambda x: dict[x], dec_list[0])) dec_list[1] = reduce(lambda x, y: x * 0.1 + y , list(map(lambda x: dict[x], dec_list[1]))[::-1]) return dec_list[0] + dec_list[1] * 0.1
Sign in to make a reply
表面不约谁信