# 获取list中指定元素的索引 a = [2,4,3,5,6,8] c = [] for i in a: c.append(a.index(i)) print(c)
运行结果为:
获取指定元素的下标
a = [2,4,3,5,6,8] print(a.index(3))
运行结果为:
# 获取list中指定元素的索引 a = [2,4,3,5,6,8] c = [] for i in a: c.append(a.index(i)) print(c)
运行结果为:
获取指定元素的下标
a = [2,4,3,5,6,8] print(a.index(3))
运行结果为: