python列表每个元素和其余元素比较
获得列表每个元素和其余元素比较时具有相同元素的元素,比如a,与a 具有相同元素的是{‘a’, ‘d’},{‘d’, ‘a’, ‘b’}
tep =[{'a'} ,{'b', 'd'}, {'a', 'd'}, {'d', 'a', 'b'} ,{'d', 'c', 'b'}]
temps = [] # 存放每次比较获得的应该删除掉的元素
j = 0
while j < len(tep):
k = j + 1
while k < len(tep):
if tep[j].issubset(tep[k]) == True:
print('tepk', tep[j], tep[k])
temps.append(tep[k])
k = k + 1
print('diyi',tep[j])
print('linshi', temps)
j = j + 1