我正在尝试具有相同的行为,但是我想检查url
字典是否包含唯一值,而不是检查完整的字典。
def unique(data):
result = {}
for key,value in data.items():
new_list = []
for item in value:
if item not in new_list:
new_list.append(item)
result[key] = new_list
return result
games = {
"games":[
{
"city":"Santa Monica,CA","company":"rockstar","date":{
"display":"24 days ago","timestamp":1570721082
},"game":"akakkak","challenge":"leel","url":"https://www.game.com/12757a575/aaashs/2222"
},{
"city":"Santa Monica,"game":"akak2kak","url":"https://www.game.com/12757a575/aaashs/2222"
}
]
}
print(unique(games))
我希望"url":"https://www.game.com/12757a575/aaashs/2222"
的输出在同一键中没有相同的值