Discuss / Python / 第三题

第三题

Topic source

bdjkmxj

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

    lisNoDot = list(s)

    lisNoDot.remove('.')

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

    def char2num(q):

        return DIGITS[q]

    def fn(x, y):

        return x*10+y

    listbak = list(s)

    listbak.reverse()

    Point = listbak.index('.')

    return reduce(fn, list(map(char2num, lisNoDot)))/(10**Point)


  • 1

Reply