#-----------------方法一-------------------------- list1 = [1,2,3,4,5,6,7,8,9] list2 = [] for i in range(len(list1)): if i % 2 ==1: list2.append(list1[i]) else: continue print(list2) #-----------------方法二--------------------------- list1 = [1,2,3,4,5,6,7,8,9] i = 0 while i < len(list1): del list1[i] i+=1 print(list1)
原文地址:https://www.cnblogs.com/m-r-lee/p/12195526.html
时间: 2024-10-06 00:14:38