def page(li, num):
"""
:param li: 需要分页的列表
:param num: 每一页页码数量
:return: 分页后列表
需要导入math模块
"""
zu = math.ceil(len(li)/num)
new_list = []
n = 0
while True:
if n == (zu - 1):
new_list.append(li3[n:])
break
page = li3[n:(n + num)]
del li3[0:(num-1)]
new_list.append(page)
n += 1
return new_list
list = [1,2,3,3,3,4,5,5,3,4,3,1,2,4,5,6,78,5,67,8,6,5,4,3,2,5,7,9,2,4]
new_list = page(list, 7)
print(new_list)
# 输出 [[1, 2, 3, 3, 3, 4, 5], [5, 3, 4, 3, 1, 2, 4], [5, 6, 78, 5, 67, 8, 6], [5, 4, 3, 2, 5, 7, 9], [2, 4]]