Discuss / Python / 字符串变浮点数

字符串变浮点数

Topic source
L=s.split('.')
def f(n):
    i={'1':1,'2':2,'3':3,'4':4,'5':5,'6':6} 
    return i[n]
def k(x,y):
    return x*10+y
def j(a):
    while a>=1:
        a=a/10
    return a
return reduce(k,map(f,L[0]))+j(reduce(k,map(f,L[1]))) 

  • 1

Reply