更新时间:2023-11-01 20:55:04
我对另一个问题的答案(您完全忽略了它!)表明您声称
My answer to your other question, which you completely ignored!, shows you're wrong in claiming that
该问题的答案没有 保持订单"
The answers of that question did not keep the "order"
对于一个非常大的列表,可能是最快的方法,如果要保留剩余项目的确切顺序,请执行以下操作:
Probably the fastest approach, for a really big list, if you want to preserve the exact order of the items that remain, is the following...:
biglist = [
{'title':'U2 Band','link':'u2.com'},
{'title':'ABC Station','link':'abc.com'},
{'title':'Live Concert by U2','link':'u2.com'}
]
known_links = set()
newlist = []
for d in biglist:
link = d['link']
if link in known_links: continue
newlist.append(d)
known_links.add(link)
biglist[:] = newlist