Discuss / Python / 第三题,经过大佬们的启发才想出来

第三题,经过大佬们的启发才想出来

Topic source

z_潇旭

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

def str2float(s): n = s.replace('.','') DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} def abc(s): return DIGITS[s] return reduce(lambda x,y:x*10+y,map(abc,n))/1000

都交给我8

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

然而你这个还是错的,小数点后面不是三位数的时候,就是错的了


  • 1

Reply