发布时间:2019-09-24 08:34:56编辑:auto阅读(2694)
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实现零钱找零的三种方法
48853
47913
38701
35852
30278
27025
26062
20894
20692
19058
492°
580°
598°
603°
581°
567°
627°
699°
822°
920°