Discuss / Python / 新手打卡

新手打卡

Topic source

邹lh

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

def str2float(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} s1,s2 = s.split('.') def char2num(s): return DIGITS[s] def f1(x,y): return x*10+y x1 = list(map(char2num,s1)) x2 = list(map(char2num,s2)) return reduce(f1,x1)+reduce(f1,x2)/(10**(len(s2)))


  • 1

Reply