Python - 将一个dicts列表分成单独的dicts

Lau*_*ber 2 python dictionary list network-analysis

我正在使用HITS算法进行社交网络分析.该算法的使用产生两种不同的度量:hub-score和authority-score.生成一个包含两个基于这些度量的字典的列表,其中一个字典的索引为0,另一个字典的索引为0.

如何删除总体列表以获取两个单独的词典?代码和输出如下:

G = nx.read_weighted_edgelist('data.csv', create_using=nx.DiGraph())
HITS_scores = list(nx.hits(G))

Output:
List = Index     Type      Value
       0         dict      {'node1': 0.023, 'node3': 0.017.....'node17': 0.045}
       1         dict      {'node2': 0.042, 'node4': 0.002.....'node16': 0.032}

Desired Output:
hub_score =      dict      {'node1': 0.023, 'node3': 0.017.....'node17': 0.045}
auth_score =     dict      {'node2': 0.042, 'node4': 0.002.....'node16': 0.032}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

PS我试过寻找答案,但一直无法找到解决方案

gil*_*lch 5

您可以使用对象列表的分配来解包迭代,如下所示

hub_score, auth_score = nx.hits(G)
Run Code Online (Sandbox Code Playgroud)