发布时间:2019-09-24 08:34:56编辑:auto阅读(2747)
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实现零钱找零的三种方法
49316
48504
39205
36295
30710
27523
26519
21344
21192
19540
183°
371°
385°
476°
771°
544°
1219°
1238°
1173°
1164°