c=[1,1,1,1,2,2,2,3,3,4,4,4,4,4,5,5,5,] a = [] x = [] for i in range(0,len(c)): if i + 1 < len(c): if c[i] == c[i + 1]: x.append(c[i]) else: x.append(c[i]) a.append(x) x = [] else: x.append(c[len(c) - 1]) a.append(x) print(a) 运行结果: [[1, 1, 1, 1], [2,…