如何从字典中 select 所有时间以及时间发生点的名称?

How do I select all the timing together with the name of the point at which the time occurs from a dictionary?

这是字典的一段:

{'WayPoint46_WayPoint39': [(14.547985, datetime.datetime(2016, 5, 23, 18, 45, 47), True)], 'WayPoint39_WayPoint38': [(7.208904, datetime.datetime(2016, 5, 23, 18, 46, 13), True)], ... }

我想select 例如,WayPoint46_WayPoint39, 14.547985.

感谢您的提前帮助。

可能是最简单的解决方案:

for key, value in input_dict.items():
    print(key, value[0][0])

input_dict 等于您的输入,输出如下:

WayPoint46_WayPoint39 14.547985
WayPoint39_WayPoint38 7.208904

求和可以使用 sum() 函数:

print(sum([value[0][0] for value in input_dict.values()]))