在python中对list求和及求积


# 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))


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM