Python 多维数组求下标

2017-01-12 07:47:51来源:作者:人点击

def list_index(List,sub_ele,Index=[],a=0):for i in List: print 'search...'+`Index`if  isinstance(i,list):  Index.append(a)x=list_index(i,sub_ele,Index,a=0)if x:return xIndex.pop()elif sub_ele == i:Index.append(a)print 'success:'+`Index`return Indexa+=1
List=['a','i',['b','c'],'e',['f',['g',['z'],['y',['k']],['j',['n',['m'],'w'],'x']],'h'],'l']sub_ele='y'print list_index(List,sub_ele)


本文出自 “运维学习之路” 博客,请务必保留此出处http://kk15320.blog.51cto.com/4848160/1891215

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台