【发布时间】:2013-11-21 03:36:03
【问题描述】:
我想使用 pyMongo 将以下数据结构插入 MongoDB。唯一的问题是我使用的 xml 数据具有我想要保留的重复键,以及“关键字”和“相关性”子字典键。
for entity in root.find('output'):
oc_entities[entity.tag] = {'keyword' : entity.text,
'relevance' : entity.get('relevance')}
以上内容正在根据需要进行工作和插入,购买我丢失了大部分重复的键值数据。我知道字典不允许重复键,但有点难倒替代!
提前致谢
【问题讨论】:
标签: python python-2.7 dictionary pymongo