Discuss / Python / 第三题

第三题

Topic source

蓝萨节

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

def str2float(s): l1, l2 = s.split('.') ret1 = reduce(fn, map(str2digit, l1)) ret2 = reduce(fm, map(str2digit, l2[::-1]))/10 return ret1+ret2

def fn(x, y): return 10*x + y

def fm(x, y): return x/10 + y

def str2digit(a): dict = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} return dict[a]


  • 1

Reply