麻烦循环多维dict

时间:2014-06-10 14:54:07

标签: python python-2.4

使用python 2.4:

如何迭代这个数据结构:

if device not in alerts:
    alerts[device] = {}
alerts[device]['mntpt'] = mntpt
alerts[device][timestamp] = { 'r_ops': r_ops, 'r_avgrtt': r_avgrtt, 'r_avgexe': r_avgexe, 'w_ops': w_ops, 'w_avgrtt': w_avgrtt, 'w_avgexe': w_avgexe }

我想对每个设备的时间戳dicts中的值进行一些计算。

任何帮助......

1 个答案:

答案 0 :(得分:-1)

这是你正在寻找的吗?

for device in alerts:
    for timestamp in alerts[device]:
        #Do stuff with timestamp