看板 [ Python ]
討論串[問題] 關於 index 用法
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者plom (plom)時間17年前 (2008/07/07 15:27), 編輯資訊
1
0
0
內容預覽:
大家好, 請教各位:. a=['abc','cdrf','abc','erd','abc']. 則 a.index = 0. 是否可有辦法一次找出所有"abc" 的 index 位置?. 例 a.index = [0,2,4]. --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From:

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者ya790206 (殘雲奪月)時間17年前 (2008/07/07 16:05), 編輯資訊
0
0
0
內容預覽:
看一下內建函數好像沒有這個功能. 自己寫一個獻醜一下. def indexs(data,sub):. i=0. result=[]. try:. while 1:. i=data.index(sub,i). result.append(i). i+=1. except ValueError,e:.
首頁
上一頁
1
下一頁
尾頁