📌  相关文章
📜  如何在python代码示例的列中计算连续的一系列正值或负值

📅  最后修改于: 2022-03-11 14:45:55.568000             🧑  作者: Mango

代码示例1
a = [0,0,1,1,1,0,0,1,0,1,1]
b = [0,0,0,0,0,0,0,0,0,0,0]

for i in range(len(a)):
    if a[i] == 1:
        b[i] = b[i-1] + 1
    else:
        b[i] = 0