Discuss / Python / 第三题交作业---昨晚搞了一晚上

第三题交作业---昨晚搞了一晚上

Topic source

-Otokaze-

#1 Created at ... [Delete] [Delete and Lock User]
def str2int(s):
    return {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9}[s]
def int2float(x,y):
    ly=len(str(y))
    return x*10**ly+y
l=s.split('.')
l1=reduce(int2float,map(str2int,l[0]))
l2=reduce(int2float,map(str2int,l[1]))
lenl2=len(l[1])
return l1+(l2*10**(-lenl2))

  • 1

Reply