Discuss / Python / 也交作业试试

也交作业试试

Topic source
def str2float(s):
    def str2int(b):
        return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '.': '.'}[b]
    a = list(map(str2int, s))
    b = len(a) - 1 - a.index('.')
    a.remove('.')
        return reduce(lambda x, y : x * 10 + y, a)/ 10.0 ** b

  • 1

Reply