回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我有一个为机器生成对象的Python文件。下面是示例</p>
<pre><code> {
"Date/Time": "2019-01-01 8:00:00",
"Availability": 68,
"Performance": 70,
"Quality": 70
}
</code></pre>
<p>我有另一个Python文件,其中包含JSON数据,如下所示。如何将JSON对象插入到“machines”下的数据数组(第18行,空括号),而不将对象复制并粘贴到第二个文件中?它是否涉及将一个Python文件写入另一个Python文件</p>
<pre><code>[{
"countries": [{
"countryID": "79",
"countryName": "USA",
"states": [{
"stateID": "58",
"stateName": "VA",
"cities": [{
"cityID": "13",
"cityName": "RES",
"locations": [{
"locationID": "48",
"locationName": "RTC",
"locationZIP": 11111,
"machines": [{
"machineID": "98",
"machineName": "RED",
"data": []
}]
}]
}]
}]
}]
}]
</code></pre>
<p>最终目标:</p>
<pre><code>[{
"countries": [{
"countryID": "79",
"countryName": "USA",
"states": [{
"stateID": "58",
"stateName": "VA",
"cities": [{
"cityID": "13",
"cityName": "RES",
"locations": [{
"locationID": "48",
"locationName": "RTC",
"locationZIP": 11111,
"machines": [{
"machineID": "98",
"machineName": "RED",
"data": [{
"Date/Time": "2019-01-01 8:00:00",
"Availability": 68,
"Performance": 70,
"Quality": 70
}]
}]
}]
}]
}]
}]
}]
</code></pre>