使用for循环嵌套字典

时间:2018-04-24 16:16:27

标签: python-3.x

我正在尝试在当前代码中的字典中添加字典,就像这样!

    i = 0
    A ={}
    x = [...]
    for i in x:
        (a,b) = func(x)#this returns two different Dictionaries as a and b 
          for key in a.keys():
            A[key] = {}
            A[key][i] = a[key]
        print('A:',A)

当我执行它时,我得到了' A'整个循环中打印的字典!但是,我需要在一个字典中说:" C" 我该怎么做?

0 个答案:

没有答案