如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# the basic way s = 0 for x in range ( 10 ): s + = x # the right way s = sum ( range ( 10 )) # the basic way s = 1 for x in range ( 1 , 10 ): s * = x # the other way from operator import mul reduce (mul, range ( 1 , 10 )) |
以上这篇在python中实现对list求和及求积就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qianggezhishen/article/details/46532441