python中,无论是对的list求和还是求积,我都给出了两种方法。
1。对list求和
1.1
s=0
for i in range(10):
s+=i
1.2
s=sum(range(10))
2.1
s=0
for i in range(1,10):
s*=i
2.2
from operator import mul
reduce(mul,range(1,10)
python中,无论是对的list求和还是求积,我都给出了两种方法。
1。对list求和
1.1
s=0
for i in range(10):
s+=i
1.2
s=sum(range(10))
2.1
s=0
for i in range(1,10):
s*=i
from operator import mul
reduce(mul,range(1,10)