python 删除列表中的字典元素
data={"data":[{"end_point": [-2.45, 5.04], "hotelid": "demo_one", "begin_point": [-4.37, 6.36], "name": "a5", "floor": "1"},{"end_point": [-2.45, 5.04], "hotelid": "demo_one", "begin_point": [-4.37, 6.36], "name": "a2", "floor": "1"} ,{"end_point": [-2.45, 5.04], "hotelid": "demo_one", "begin_point": [-4.37, 6.36], "name": "a3", "floor": "1"}]} print("before:\n\n",data,"\n\n") temp=-1 k=0 for i in data['data']: if(i["name"]=="a3"): temp=k break k=k+1 if(temp!=-1): del data['data'][temp] print("after:\n\n",data)