python 计算列表中某个元素连续出现的次数
a = [1, 2, 3, 4, 21, 1, 1, 2, 3, 1, 1, 1]
b = 2 # b的值为要求的数字
t = 0
w = 1
for k, v in enumerate(a):
if k > 0:
if v == b and a[k - 1] == b:
t += 1
if w < t:
w = t
else:
t = 1
print(w)