相关疑难解决方法(0)

如何在Python中切换字典的嵌套结构

如果我有以下字典:

dict_a = {'a': {'x': 0, 'y': 1, 'z': 2},
          'b': {'x': 3, 'y': 4, 'z': 5}}
Run Code Online (Sandbox Code Playgroud)

将字典结构切换为的最佳方法是什么:

dict_b = {'x': {'a': 0, 'b': 3},
          'y': {'a': 1, 'b': 4},
          'z': {'a': 2, 'b': 5}}
Run Code Online (Sandbox Code Playgroud)

python dictionary nested

3
推荐指数
1
解决办法
220
查看次数

标签 统计

dictionary ×1

nested ×1

python ×1