第三题
Topic source修改后:
!/usr/bin/env python3
-- coding: utf-8 --
from functools import reduce
def str2float(keys): return {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9,'.':-1}[keys]
def fun(x, y): return x10+y s='1230.4567' s1,s2 = s.split('.') s3 = len(s2) print(s1,s2,s,s3) N=reduce(fun,map(str2float,s1+s2))/10*s3 print(N)
- 1
lianwade3
!/usr/bin/env python3
-- coding: utf-8 --
from functools import reduce
def str2float(keys): return {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9,'.':-1}[keys]
def fun(x, y): return x10+y s='123.456' s1,s2 = s.split('.') s3 = len(s2) print(s1,s2,s,s3) N=reduce(fun,map(str2float,s1+s2))/10*s3+1 print(N)