我有一个列表列表,每个列表都有一个重复序列。我正在尝试计算列表中重复整数序列的长度:
list_a = [111,0,3,1,111,0,3,1,111,0,3,1]
list_b = [67,4,67,4,67,4,67,4,2,9,0]
list_c = [1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,23,18,10]
哪个会返回:
list_a count = 4 (for [111,0,3,1])
list_b count = 2 (for [67,4])
list_c count = 10 (for [1,2,3,4,5,6,7,8,9,0])
欢迎任何建议或提示。我现在正在尝试使用 re.compile 来解决它,但是它并不完全正确。