发布时间:2019-09-24 08:34:56编辑:auto阅读(2729)
print pos
print i
song@ubuntu:~$
4》法四:
song@ubuntu:~$ vi find_2.py
song@ubuntu:~$ more find_2.py
l=[2,2,3,4,5,1,2,3,1,2,3,4,5]
for i in range(l.count(2)):
if i==0:
pos=l.index(2)
else:
pos=l.index(2,pos+1)
print pos
song@ubuntu:~$ python find_2.py
0
1
6
9
5》法五:
song@ubuntu:~$ vi find_2.py
song@ubuntu:~$ more find_2.py
l=[2,2,3,4,5,1,2,3,1,2,3,4,5]
pos=-1
for i in range(l.count(2)):
pos=l.index(2,pos+1)
print pos
song@ubuntu:~$ python find_2.py
0
1
6
9
(完)
上一篇: Python能做什么?怎么小学生都在学!
下一篇: 用python实现零钱找零的三种方法
49151
48298
39023
36146
30555
27352
26356
21183
21026
19365
146°
151°
250°
439°
294°
962°
992°
977°
980°
937°