📜  compter des valeur Continuouss en python 代码示例

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

代码示例1
>>> from itertools import groupby
>>> def groups(l):
...     return [sum(g) for i, g in groupby(l) if i == 1]
...
>>> groups([0,1,0,0,0])
[1]
>>> groups([0,0,1,1,0])
[2]
>>> groups([1,1,0,1,1])
[2, 2]