How to access elements in a dict_values?

Question:

I have a dict :

{49: {'created_at': '2018-11-07T13:25:12.000Z', 'url': 'https://www.test.com'}}

I would like to get ‘created_at’.

I’ve attempt through different methods but without a success… I thought this approach would works:

result = di.values()[0] but I get a TypeError: 'dict_values' object does not support indexing

But it doesn’t.

Answers:

You should use: di[49]['created_at']

or:

list(di.values())[0]['created_at']

Answered By: Gabio

You may use dict items for it.

dic = {49: {'created_at': '2018-11-07T13:25:12.000Z', 'url': 'https://www.test.com'}}
for j,k in dic.items():
     print(k['created_at'])
Answered By: Semih SARI