如下所示:
# 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求和及求积就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“在python中实现对list求和及求积”评论...