看板
[ Python ]
討論串[問題] 在任意維度的 List 中找某元素的位置?
共 2 篇文章
首頁
上一頁
1
下一頁
尾頁
內容預覽:
如果是List的話就遞迴下去找,找到最後如果符合的話就回傳index. def Find(arr, value, current_idx):. if not isinstance(arr, list):. if arr == value:. return [current_idx]. else:.
(還有160個字)
內容預覽:
不好意思,因為用習慣了 Mathematica 的 Position 指令,. 所以小弟正在用 Python 寫一個執行相同功能的指令。. 現在卡住的點是,如果知道輸入的 List 是二維的,. 當然就是用兩層的 for loop:. def position(arr,cri):. index=[]
(還有261個字)
首頁
上一頁
1
下一頁
尾頁