当前位置:主页 > 软件编程 > Python代码 >
时间:2021-02-12 08:51:27 | 栏目:Python代码 | 点击:次
编写一个prod()函数,可以接受一个list并利用reduce()求积。
from functools import reduce def prod(x,y): return x * y L = reduce(prod,[3,5,7,9]) print(L)
打印结果如下: