Discuss / Python / 第三题打卡

第三题打卡

Topic source

本地的Yoyo

#1 Created at ... [Delete] [Delete and Lock User]

def str2float(s):

    def join(x,y):

        return (x*10+y)

    def digit(t):

        dig={'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9,'.':'.'}

        return dig[t]

    part=s.split('.')

    return reduce (join,map(digit,part[0])) + reduce(join,map(digit,part[1]))*(0.1**len(part[1]))


  • 1

Reply