def arr_size(arr, size):
s = []
for i in range(0, int(len(arr)) + 1, size):
c = arr[i:i + size]
if c != []:
s.append(c)

return s
if __name__ == '__main__':
a = [1, 2, 3, 4, 5, 6, 7]
print(arr_size(a, 2))

效果

[[1, 2], [3, 4], [5, 6], [7]]