我在python 3 numpy.ndarray中有以下内容:
{"_id" : "123", "text" : "some writing"}
{"_id" : "456", "text" : "some more writing"}
{"_id" : "789", "text" : "some more more writing"}
问题:
如何删除{"_id" :
和"text" :
以获取以下内容:
{"123", "some writing"}
{"456", "some more writing"}
{"789", "some more more writing"}
答案 0 :(得分:2)
以下是:
arr = [{"_id" : "123", "text" : "some writing"}, {"_id" : "456", "text" : "some more writing"}, {"_id" : "789", "text" : "some more more writing"}]
ans = [{i['_id']: i['text']}for i in arr]