小编vmi*_*nof的帖子

转换字典格式

我有一个下一格式的字典:

a = {'file': {'x': [1, 2, 3, 4], 'y': [23, 134, 571, 13]}, 
     'file2': {'x': [1, 2, 3, 5], 'y': [123, 215, 21, 123]}}
Run Code Online (Sandbox Code Playgroud)

是否有可能以这种格式转换这个字典(这里的键是所有x之间的联合):

{'1': {'file': 23, 'file2': 123}, '2': {'file': '134', 'file2': 215}, ..., 
 '4': {'file': 13, 'file2': '-'}, '5': {'file': '-', 'file2': '123'}}
Run Code Online (Sandbox Code Playgroud)

我只是想不出怎么做.

python dictionary

-1
推荐指数
1
解决办法
89
查看次数

标签 统计

dictionary ×1

python ×1