当前位置:主页 > 软件编程 > Python代码 >

python 列表输出重复值以及对应的角标方法

时间:2021-05-19 09:40:20 | 栏目:Python代码 | 点击:

如下所示:

a = [99,1,2,1,3,4]
# 集合存储重复数据
b=set()
for i in a:
  if a.count(i)>1:
    b.update([i])
dict ={}
# 遍历重复数据
for j in b:
  list = []
  for A in range(len(a)):
    if j == a[A]:
      list.append(A)

  dict[j] = list
print(dict)

您可能感兴趣的文章:

相关文章