擅长:python、mysql、java
<p>让我们从您想要得到的内容开始:一个站点字典,其中每个站点的值是一个字典,其中包含来自每个报表的<code>value</code>的列表。因此,首先收集常量部分,然后收集列表中的值:</p>
<pre><code>new_stations = dict()
for station in results:
# Copy the fixed info
fixed = station[0]
name = fixed["station_number"]
this_station = { "formula": fixed["formula"],
"station_number": name,
"value": []
}
# Now collect the values
for record in station:
this_station["value"].append(record["value"])
# Save the station in our main dict
new_stations[name] = this_station
</code></pre>