在Python中进行列表的合并可以使用"+"符号,例如:
list1 = [1, 2, 3] list2 = [4, 5, 6] merged_list = list1 + list2 print(merged_list)
输出结果为:[1, 2, 3, 4, 5, 6]
在Python中进行列表的拆分可以使用切片操作,例如:
big_list = [1, 2, 3, 4, 5, 6] small_list1 = big_list[:3] small_list2 = big_list[3:] print(small_list1) print(small_list2)
输出结果为: [1, 2, 3] [4, 5, 6]