任何人都可以幫助我,我有一個列表2D,我想知道2D中myList的索引,但我只知道該索引的第一個值,例如我只知道'a2'
,我想要知道,包含'a2'
在第一值列表的索引,因爲我想訪問列表的例子,我想通過知道'a2'
訪問['a2', 'b1']
:2維python列表索引
myList2= [['a1', 'b2', 'c1'], ['a2', 'b1'], ['b1', 'c2'], ['b2', 'c1'], ['c1'], ['c2']]
其他情況下....如果myList2是類對象的列表點。
另請參閱[這裏](http://stackoverflow.com/questions/11963711/what-is-the-most-efficient-way-to-search-nested-lists-in-python),[這裏](http://stackoverflow.com/questions/6889785/python-how-to-search-an-item-in-a-nested-list),和更多類似的問題。 – TigerhawkT3