python 列表求和,最大值,最小值,乘积
numList = [1,2,3,4,5] sum = sum(numList) #sum = 15 maxNum = max(numList) #maxNum = 5 minNum = min(numList) #minNum = 1 from operator import mul prod = reduce(mul, numList, 1) #prod = 120 默认值传1以防空列表报错
numList = [1,2,3,4,5] sum = sum(numList) #sum = 15 maxNum = max(numList) #maxNum = 5 minNum = min(numList) #minNum = 1 from operator import mul prod = reduce(mul, numList, 1) #prod = 120 默认值传1以防空列表报错