第一题:
def capitalize(L): return list(map(lambda a: a[0].upper() + a[1:].lower(), L)) # 或者 def normalize(L): return list(map(lambda a: a.title(), L))
第二题:
def prod(L): return reduce(lambda x, y: x * y, L)
第三题:
def str2float(str): s = str.replace('.', '') num = 10 ** (len(str) - str.find('.') - 1) return reduce(lambda a, b: a * 10 + b, map(lambda v:int(v),s)) / num
Sign in to make a reply
最帅的仔
第一题:
第二题:
第三题: