介绍
本篇文章给大家分享的是有关利用Python怎么查找列表中元素的下标,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
<>强如下所示:强>
# !/usr/bin/env Python # _ * _ 编码:utf-8 _ * _ name =,(& # 39;你好# 39;,,& # 39;& # 39;,,& # 39;一个# 39;,,& # 39;b # 39;,, & # 39; c # 39;,, 1,, 2,, 3,, & # 39;你好# 39;,,& # 39;& # 39;,,& # 39;一个# 39;,,& # 39;b # 39;,, & # 39; c # 39;,, 1,, 2,, 3] first_pos =0 for 小姐:拷贝范围(name.count (2)):=,名字,new_list  [first_pos:]=,,next_pos  new_list.index (2), + 1 ,print & # 39; find & # 39;, first_pos +, new_list.index (2) +=,first_pos next_pos
注意:查找出列表中所有的某个元素