Discuss / Python / zuoye哈哈哈哈哈哈哈哈哈我终于搞出来啦

zuoye哈哈哈哈哈哈哈哈哈我终于搞出来啦

Topic source

墨染苍瞳

#1 Created at ... [Delete] [Delete and Lock User]
n = s.find('.')
L = s[0:n]+s[n+1:]
C = []
for c in L:
    C.append(int(c))
f = reduce(lambda x,y:(x*10+y),C)
f = f/1000
return f

墨染苍瞳

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

这是更标准的: DIGITS = {'.':0,'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9} F =s.find('.') def d(x,y): return x10+y def x(x,y): return x0.1+y def c(s): return DIGITS[s] return reduce(d,list(map(c,s))[0:F])+reduce(x,list(map(c,s))[F+1:][::-1])*0.1


  • 1

Reply