我似乎无法遍历字典中的列表。
data={}
data['people']=[]
data['people'].append({'Name':'Michael'})
data['people'].append({'Name':'Paul'})
for idx, val in data['people']:
if val == {'Name':'Michael'}:del data['people'][idx]
ValueError:解包需要多于1个值
答案 0 :(得分:2)
这就是你想要的:
data={}
data['people']=[]
data['people'].append({'Name':'Michael'})
data['people'].append({'Name':'Paul'})
for i in data['people']:
if i == {'Name':'Michael'}:
data['people'].remove(i)