假设我有一个json文件,如-
{
"course": "hwjxh",
"school_id": 1234,
"name_list": [
{
"name": "xyzzy",
"marks": 97
},
{
"name": "abc",
"marks": 44
},
{
"name": "qwe",
"marks": 78
},
{
"name": "def",
"marks": 90
},
{
"name": "jkl",
"marks": 80
},
{
"name": "abc",
"marks": 78
}
],
"course_id": "567",
"s_name": "abc public school"
}
这是一个单一的对象。有数百种类似的物体。 我所做的是从“名称列表”中访问每个“名称”,并使用一些规则清理它。在这个过程中,一些常见的名字被删除了。 现在我想将清理后的数据更新回json文件。请注意,如果过滤了公共名称,则在将数据更新回json文件时,也应删除相应的标记。 有人能帮我吗? 我将这些json对象放在一个文件中,我使用“smart_open”库打开了这个文件
让我用一个例子向您展示如何做到这一点:
相关问题 更多 >
编程相关推荐