Discuss / Python / 第三题

第三题

Topic source

If you like

#1 Created at ... [Delete] [Delete and Lock User]
def str2float(s):
    def multi(x, y):
        return x * 10 + y

    L1, L2 = s.split('.')
    return reduce(multi, map(int, L1)) + reduce(multi, map(int, L2)) * pow(0.1, len(L2))

  • 1

Reply