第三题
Topic source格式...
def str2float(str): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} dot = str.index('.')
def str2num(s):
return digits[s]
def fn(x,y):
return x * 10 + y
return reduce(fn, map(str2num, str[:dot]+str[dot+1:]))/10**dot
- 1
机修贾森
from functools import reduce
def str2float(str): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} dot = str.index('.')