rank | ▲ | ✰ | vote | url |
---|---|---|---|---|
42 | 465 | 90 | 791 | url |
查找列表中某个元素的下标
比如["foo","bar","baz"]
和它的一个元素"bar"
,用什么方法能找到它的下标(1)?
>>> ["foo","bar","baz"].index('bar')
1
参考资料:Data Structures > More on Lists
原文: https://taizilongxu.gitbooks.io/stackoverflow-about-python/content/42/README.html