1
wog 2013-02-06 01:42:36 +08:00
for i in [1,2,3]:
if i==2: conitnue print(i) |
2
wog 2013-02-06 01:43:25 +08:00
囧continue都拼错了,你改一下吧
|
3
BOYPT 2013-02-06 09:52:57 +08:00
不可能。
|
4
VYSE 2013-02-06 10:02:26 +08:00 via Android
模仿C循环方式不就行了
|
5
yujnln 2013-02-06 10:06:58 +08:00
print [i for i in [1,2,3] if i!=2]
|
6
sivacohan 2013-02-06 21:06:37 +08:00
goto~
|
7
dotbuddle 2013-02-06 22:39:49 +08:00
列表是不是也有index?
|
8
Narcissu5 2013-02-07 00:22:05 +08:00
用枚举器循环,continue的同时next一下(好像更麻烦的说-_-!)
|
9
yuelang85 2013-02-07 00:55:55 +08:00 2
如果是遍历列表的话,可以remove/pop掉下一个元素
>>> l = [1,2,3,4] >>> for i, v in enumerate(l): ... if v == 2: ... x = l.pop(i+1) ... print v ... 1 2 4 |
10
yuelang85 2013-02-07 00:56:24 +08:00
>>> l = [1,2,3,4]
>>> for i, v in enumerate(l): ... ...if v == 2: ... ......x = l.pop(i+1) ... ...print v ... 1 2 4 |