#1 def normalize(name): name[0].upper()+name[1:].lower() return name #2 def prod(L): def mul(x,y) : return x*y return reduce(mul,L) #3 def str2num(s): DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} return DIGITS[s] def fn(x, y): return x * 10 + y i = s.index('.') #字符串里去掉'.',避免str2num时报错 s = s.replace('.','') return reduce(fn,map(str2num,s))/pow(10,len(s)-i)
Sign in to make a reply
°Destiny