Questions tagged «accumulate»

21
如何找到列表中数字的累计和?
time_interval = [4, 6, 12] 我想对数字求和[4, 4+6, 4+6+12],以便得到列表t = [4, 10, 22]。 我尝试了以下方法: t1 = time_interval[0] t2 = time_interval[1] + t1 t3 = time_interval[2] + t2 print(t1, t2, t3) # -> 4 10 22
92 python  list  sum  accumulate 
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.