list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # 输出结果[1,2,3][4,5,6][7.8.9] len_list = len(list) // 3 num_list = len(list) % 3 list_all = [] for num in range(len_list): list1 = list[3 * num:3 * num + +3] list_all.append(list1) list2 = list[-num_list:] list_all.append(list2) print(list_all)
标签:分割,list1,list,len,列表,num,任意,append From: https://www.cnblogs.com/wolvies/p/17545054.html