python中输出列表中重复元素的所有索引
>>> a = ["aa","bb","aa","cc","aa","dd","bb","aa","cc"]
>>> a
['aa', 'bb', 'aa', 'cc', 'aa', 'dd', 'bb', 'aa', 'cc']
>>> b = a.count("aa")
>>> b
4
>>> c = -1
>>> for i in range(b):
c = a.index("aa",c + 1,len(a))
print("aa",c)
aa 0
aa 2
aa 4
aa 7