Discuss / Python / 作业三,写的有点麻烦了

作业三,写的有点麻烦了

Topic source

    def stoList(num):

        for x in num:

            return x

    global n

    n=0

    def toFloat(x,y):

        global n

        if(n == 0):

            if(y!='.'):

                return float(x)*10 +int(y)

            else:

                n = 1        

                return x

        else:

            n += 1

            return x + int(y)/(10**(n-1))

    r = map(stoList,s)

    res = reduce(toFloat,r)

    return res


  • 1

Reply