python 遍历列表时删除元素
testObjs = ["1","2","3","1"]
# i=0
# for o in testObjs:
# testObjs.pop(i)
# print(o)
# i+=1
j=0
length = len(testObjs)
for i in range(0,length):
o = testObjs[i-j]
if(o=="1"):
testObjs.pop(i-j)
j+=1
print(testObjs)
结果