Discuss / Python / 刚刚交错格式了

刚刚交错格式了

Topic source
#P1
def normalize(name):
    def normalize1(a):
        return a[0].upper()+a[1:].lower()
    return map(normalize1,name)
#P2
from functools import reduce
def prod(L):
    def multiple(x,y):
        return x*y
    return reduce(multiple,L)

#P3
def str2float(s):
    def str2(x,y):
        return x*10+y
    def str3(x,y):
        return x/10+y
    s1,s2=s.split('.')
    s2=s2[::-1]
    a1=reduce(str2,map(int,s1))
    a2=reduce(str3,map(int,s2))/10
    return a1+a2

请问P1为什么return要用map(),不能直接return一个str吗


  • 1

Reply