def product(L): def multiply(x, y): return x*y return reduce(multiply, L)
>>> L = [1, 2, 3, 4] >>> print(product(L)) 24
供参考,求指正
from functools import reduce
Sign in to make a reply
_Ljj110719
供参考,求指正