output = {}
output['epoch time'] = obstimes
output['Number of satellites'] = numsat
output['OK flag'] = ok_flag
output['PRN'] = sats
output['Observation'] = result
output['Number of each data'] = a
我必须使用另一个键的值来拆分字典值。 我举了一个例子。
{...],
'Observation': ['22527689.086 7', None, '-578290.975 7', '-410051.96348', '22527682.94948',
'20593906.672 7', None, '-142315.266 7', '-103992.19948', '20593902.01648',
'22312367.273 6', '22312363.496 9', '-573672.801 6', '-426591.952 9', '22312363.52047',
'24649943.453 3', None, '-696710.409 3', '-499047.10745', '24649943.55545',
'21574180.359 7', None, '-440212.809 7', '-323130.81248', '21574175.09448',
'20159532.789 7', None, '35621.205 7', '26243.45049', '20159527.23449',
'24435415.719 6', '24435413.602 9', '417737.346 6', '319304.620 9', '24435413.80147',
'23108319.461 5', None, '344109.572 5', '249072.03046', '23108315.90646',
'21789481.414 7', None, '326180.505 7', '238895.05548', '21789474.12548',
'21975436.727 7', None, '277875.380 7', '205734.181 8', '21975443.121 8',
'19981973.117 9', None, '-127270.254 9', '-94211.274 9', '19981980.414 9',
'21682862.406 6', None, '242033.680 6', '179454.101 8', '21682869.020 8',
'20647552.734 7', None, '-446216.926 7', '-329944.882 9', '20647562.945 9',
'23174371.141 6', None, '-645644.090 6', '-481288.202 8', '23174379.656 8',
'21946454.047 6', None, '420271.088 6', '311362.996 8', '21946462.590 8',
'21922170.063 8', None, '-124733.763 8', '-92183.249 9', '21922177.883 9'
...],...}
我想分开这个'观察'使用另一个值列表的值。
另一个值列表是这样的;
'Number of each data' = [[80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 80, 75, 80, 80, 80, 65, 75, 75, 75,
70, 60, 50, 55, 55, 70, 65, 75, 75, 70, 65, 75, 75, 75, 65, 70,
70, 75, 75.....]]
我想使用每个数据'每个数据的数量来分割观察值。值。
我希望像这样的输出;
...], 'Observation' : [80 values][80 values][80 values]...}
请帮助或建议我。
答案 0 :(得分:0)
您应该遍历每个数据的数量'列表:
output['ObservationMatrix'] = []
counter = 0
for value in output['Number of each data']:
output['ObservationMatrix'].append(output['Observation][counter:counter + value])
counter += value
最后,从您的词典中删除(如果您愿意)输出['观察']