首页
Python
Java
PHP
IOS
NodeJS
JavaScript
HTML5
小程序
AI
sumOfList
全部标签
python - 一行列表中的平方和?
为了证明我做了某事。这是我在三行中求和的代码。l=[1,2,3,4,5];sumOfList=0foriinl:sumOfList+=i*i;printsumOfList我很好奇我可以只用一行吗? 最佳答案 是的,你可以。这里使用的是sum函数:l=[1,2,3,4,5]print(sum(i*iforiinl)) 关于python-一行列表中的平方和?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com
python
一行
section
code
sumOfList
list
sum
Home
Powered By IT.CAOLU.XIN
页面耗时:0.0508s