我有两个字典:
blocked = {'-5.00': ['121', '381']}
all_odds = {'-5.00': '{"121":[1.85,1.85],"381":[2.18,1.73],"16":[2.18,1.61],"18":\
[2.12,1.79]}'}
我想首先检查.keys()
比较(==
)是否返回True
,这里它(两者-5.00
)然后我想从中删除所有项目all_odds
中列出的键blocked.values()
。
对于上述情况,它应该导致:
all_odds_final = {'-5.00': '{"16":[2.18,1.61],"18": [2.12,1.79]}'}
我试过for loop
:
if blocked.keys() == all_odds.keys():
for value in blocked.values():
for v in value:
for val in all_odds.values():
val = eval(val)
if val.has_key(v):
del val[v]
你知道这很丑陋,而且它还不能正常工作。