def normalize(name): return name.capitalize()
def prod(L): def t(x,y): return x*y return reduce(t,L)
from math import pow def str2float(s): index=s.index('.') n=len(s)-index-1 s=s.replace('.','') def char2num(s): return {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9}[s] def cal(x,y): return x*10+y return reduce(cal,map(char2num,s))/pow(10,n)
你好,关于第一题,为什么有些同学用 name.lower().capitalize(),请问直接用 name.capitalize() 不可以吗
Sign in to make a reply
super玛丽向前冲
def normalize(name): return name.capitalize()
def prod(L): def t(x,y): return x*y return reduce(t,L)
from math import pow def str2float(s): index=s.index('.') n=len(s)-index-1 s=s.replace('.','') def char2num(s): return {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9}[s] def cal(x,y): return x*10+y return reduce(cal,map(char2num,s))/pow(10,n)