Discuss / Python / 第三题有点小长,整数和小数分开算的

第三题有点小长,整数和小数分开算的

Topic source
在此插入代码

def str2flo(str): i=0 for x in str: if(x!='.'): x=int(x); L={''} L.append(x) i=i+1 a=reduce(lambda x,y:x*10+y,L)

while(i<len(str)):
    R={''}
    R.append(str[i+1]
    i=i+1
b=reduce(lambda x,y:x*10+y,L)
w=1
while n<=len(R)
    w=w*10
f=b/w

return a+f

  • 1

Reply