发布时间:2019-07-13 11:39:20编辑:auto阅读(1598)
>>> a = [0,1,2,3,0,0,3]
>>>
for item in a :
print item
a.remove(item)
print a
输出:
0
[1, 2, 3, 0, 0, 3]
2
[1, 3, 0, 0, 3]
0
[1, 3, 0, 3]
3
[1, 0, 3]
解决方式:
# -*- coding: cp936 -*-
list1=[1,2,3,4,5]
list2=list1[:] #复制一个才能有想像中的效果
for i in list1:
print i
list2.remove(i)
list1=list2
上一篇: Python with a modula
下一篇: python 代码统计文件的行数
47481
45782
36781
34305
28952
25587
24432
19603
19093
17624
5455°
6038°
5554°
5629°
6555°
5367°
5367°
5873°
5847°
7160°