Discuss / Python / 作业3

作业3

Topic source

jsun_0701

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

def str2float(s):

  L = s.split('.')
  DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
def char2num(s):
return DIGITS[s]

def f(x, y):

return x * 10 + y
return reduce(f, map(char2num, L[0])) + reduce(f, map(char2num, L[1])) / (10 ** len(L[1]))


  • 1

Reply