Discuss / Python / 第三题

第三题

Topic source

you_you_k

#1 Created at ... [Delete] [Delete and Lock User]
from functools import reduce
def strfloat(s):
    def func1(c):
        if c=='.':
            return 0
        return int(c)
    def func2(a,b):
        if b == 0:
            return a
        return 10*a+b
    return reduce(func2,map(func1,s))/10**(len(s)-s.index('.')-1)

  • 1

Reply