def str2float(s): s = s.split('.') def str2num(t): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} return digits[t] #小数点前 def str2floatfront(x, y): return x * 10 + y #小数点后 def str2floatback(x, y): return x * 0.1 + y front = reduce(str2floatfront, map(str2num, s[0])) back = 0.1 * reduce(str2floatback, map(str2num, s[1][::-1])) return front + back
Sign in to make a reply
愚人________