标签:reduce python pytho 求和 1.2 pre nbsp name opera
python中,无论是对的list求和还是求积,我都给出了两种方法。
1。对list求和
1.1
s=0 for i in range(10): s+=i
1.2
s=sum(range(10))
2 。对list求积
2.1
s=0 for i in range(1,10): s*=i
2.2
from operator import mul reduce(mul,range(1,10)
标签:reduce python pytho 求和 1.2 pre nbsp name opera
原文地址:http://www.cnblogs.com/lingan-hong/p/6275805.html