所以,如果我有一个数组:
A = [0,1,2,3,4,5]
我能得到:
B = [0,1,2] C = [3,4,5]
A = [1,2,3,4,5,6] B = A[:len(A)//2] C = A[len(A)//2:]
如果你想要一个功能:
def split_list(a_list): half = len(a_list)//2 return a_list[:half], a_list[half:] A = [1,2,3,4,5,6] B, C = split_list(A)