def split_list(data, num_page):
'''
num_page: 打算分成多少个小列表 int类型
data: 为一个待分割的列表 list or tuple or set 类型
'''
data_list = list()
try:
n = len(data) // num_page
except Exception as e:
n = len(data)
if n == 0:
n = len(data)
for i in range(0, len(data), n):
a = data[i: i + n]
print(a)
data_list.append(a)
return data_list
网友评论