N
N
naitiq2021-11-04 15:17:40
Python
naitiq, 2021-11-04 15:17:40

How to parse a python dictionary?

as possible from

{'uID': {0: 2809037216, 1: 2809037242}, 'Дата': {0: '2021-11-03 13:53:10', 1: '2021-10-31 22:37:14'}}


do
[{'uID':2809037216,  'Дата': "2021-11-03 13:53:10" },{'uID':2809037242,  'Дата': "'2021-10-31 22:37:14" }]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2021-11-04
@naitiq

keys = list(data.keys())
result = [ { k: data[k][i] for k in keys } for i in range(len(data[keys[0]])) ]

S
Sergey Pankov, 2021-11-04
@trapwalker

Elementary. Iterate over the uid key-value pairs and query the date dictionary for the required dates using the corresponding keys, form new dictionaries and add them to a list. dump result to json.
If you don’t understand these words, then it’s too early for you to solve this problem on your own, you should learn python or go to freelancers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question