3简答题使用高阶函数reduce计算1 23456的叠乘python
代码如下:
from functools import reduce
lst = [1, 2, 3, 4, 5, 6]
result = reduce(lambda x, y: x*y, lst)
print(result)
输出结果为720,即12345*6的结果。
原文地址: https://www.cveoy.top/t/topic/ci6k 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
代码如下:
from functools import reduce
lst = [1, 2, 3, 4, 5, 6]
result = reduce(lambda x, y: x*y, lst)
print(result)
输出结果为720,即12345*6的结果。
原文地址: https://www.cveoy.top/t/topic/ci6k 著作权归作者所有。请勿转载和采集!