Discuss / Python / 第三题,收到启发再来一个

第三题,收到启发再来一个

Topic source

wujinkongxu

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

def str2float(s): x = s.find('.') s = s[:x] + s[x+1:] y= len(s) dic_number = {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9} def char2num(s): return dic_number[s] def fn(x, y): return x 10 + y return reduce(fn, map(char2num, s)) / (10*(y-x))

wujinkongxu

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

倒数第二句少了个星号,应该是x乘以10

wujinkongxu

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

星号显示有问题啊:倒数第二句少了个星号,应该是x乘以10,最后一句10的(y-x)次方,也少了一个星星


  • 1

Reply