Python 官方文档:入门教程 => 点击学习
# the basic way s = 0 for x in range(10): s += x # the right way s = sum(range(10)) # the basic way s = 1 fo
# 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))
--结束END--
本文标题: 在python中对list求和及求积
本文链接: https://lsjlt.com/news/191633.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0