发布时间:2019-09-24 08:34:56编辑:auto阅读(2615)
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实现零钱找零的三种方法
48455
47340
38226
35466
29923
26629
25602
20549
20245
18669
67°
80°
184°
132°
151°
274°
341°
336°
311°
403°