Discuss / Python / 函数用一行代码可以搞定

函数用一行代码可以搞定

Topic source

遥望君山

#1 Created at ... [Delete] [Delete and Lock User]
from functools import reduce

def product(x,*args):
    return reduce(lambda a, b: a*b, (x,) + args)

  • 1

Reply