1
我有我的代码在这里这样的,我想更新列表内的一些项目:更新Python字典元素给人以[]
coordinates = mongo_query.get_items({})
for json in coordinates:
json["person"] = "test"
json["location"] = "test"
for j in range(0, len(json["types"])):
json["types"][j] = "test"
new_coordinates = coordinates
这里的时候,我调试变量new_coordinates是空的是这样的:'[]'
坐标的结果,如果我这样做json_util.dumps(coordinates)
它给出了这样的:
coordinates= [{"name": "my name", "timestamp": {"$date": 1459002562091}, "longitude": 20.169550966746304, "location": "Work", "victim": {"language": "English", "locality": "Bern", "gender": "Other", "region": "Gabon", "birthday": {"$date": 506736000000}, "nationality": "United States", "ethnicity": "Bosnian"}, "person": "Stranger", "latitude": 43.05529651674635, "personGender": "Male", "types": ["Shouting"]}, {"name": "my name", "timestamp": {"$date": 1455632962091}, "longitude": 21.292620354706038, "location": "Public Space", "victim": {"language": "English", "locality": "Ferizaj", "gender": "Other", "region": "Kosovo", "birthday": {"$date": 601516800000}, "nationality": "Canada", "ethnicity": "Turkish"}, "person": "Waiter", "latitude": 42.81558228232729, "personGender": "Male", "types": ["Comments", "Whistling"]}]
为什么会这样,我不明白为什么我不能更新Ë在坐标列表上放置什么,以及它为什么会给出一个空列表?有人能帮助我吗?
编辑:
所以看到的坐标更好地在这里:Jsonblob link
你介意漂亮的印刷'coordinates'?目前阅读有点奇怪。 – erip
@erip请检查我所做的修改,我添加了一个jsonblob链接,以便您可以更好地看到它? – EgzEst
是的,谢谢。 – erip