1. 程式人生 > >Python 多維字典

Python 多維字典

>>> multiUsers ={'0': {'0':{'harq':0,
                           'time':1,
                           'tran':2},
                       '1':{'harq':4,
                            'time':5,
                            'tran':6}},
                  '1': {'0':{'harq':0,
                             'time'
:1, 'tran':2}, '1':{'harq':4, 'time':5, 'tran':6}}} >>> for i in multiUsers.keys(): print 'user:',i,'\t' for j in multiUsers[i].keys(): print ' process:',j for
z in multiUsers[i][j].keys(): print ' ',z,multiUsers[i][j][z] user: 1 process: 1 trans 6 harq 4 time 5 process: 0 trans 2 harq 0 time 1 user: 0 process: 1 trans 6
harq 4 time 5 process: 0 trans 2 harq 0 time 1 >>> multiUsers['1']['1'] {'trans': 6, 'harq': 4, 'time': 5}