发布时间:2019-09-24 08:34:56编辑:auto阅读(2653)
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实现零钱找零的三种方法
48609
47599
38392
35615
30067
26786
25792
20683
20424
18822
100°
187°
222°
243°
237°
249°
284°
323°
451°
438°