我有几个这样的列表:
Pargs = [args.Pee, args.Pem,...,args.Pet] # 9 elements of boolean type
indices = [(0,0),(0,1),...,(2,2)] # 9 possible combinations (i,j), i = 0,1,2; j = 0,1,2
D = [{},{},...,{}] # 9 dictionaries, desired result
我希望看到的结果应该像这样:
我想要看到的结果应该是这样的:
D = [{event:args.Pee,i:0,j:0},{event:args.Pem,i:0,j:1},...{event: args.Pet,i:2,j:2}]
字典必须按照上图所示的顺序排列。
我尝试过。
for d in D:
for i in range(3):
for j in range(3):
d['i'],d['j'] = i,j
但这并不起作用。我已经尝试过使用zip(),product(),dict()等多种算法,但都没有成功...
Pargs[0]
和indices[0]
、Pargs[1]
和indices[1]
等组合起来吗? - glibdud