def normalize(s):
result = []
for i,c in enumerate(s):
if i == 0 :
result.append(c.upper())
else:
result.append(c.lower())
return ''.join(result)
def prod(L):
def p(x,y):
return x*y
return reduce(p,L)
def str2float(s):
int_str=(s.split('.'))[0]
float_str=(s.split('.'))[1]
def char2num(v):
digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
return digits[v]
def com(x,y):
return x*10+y
return reduce(com,map(char2num,int_str))+reduce(com,map(char2num,float_str))/(10**(len(float_str)))
Sign in to make a reply
我们聊聊天气
def normalize(s):
result = []
for i,c in enumerate(s):
if i == 0 :
result.append(c.upper())
else:
result.append(c.lower())
return ''.join(result)
def prod(L):
def p(x,y):
return x*y
return reduce(p,L)
def str2float(s):
int_str=(s.split('.'))[0]
float_str=(s.split('.'))[1]
def char2num(v):
digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}
return digits[v]
def com(x,y):
return x*10+y
return reduce(com,map(char2num,int_str))+reduce(com,map(char2num,float_str))/(10**(len(float_str)))