E
E
ekzotika2020-09-03 17:51:10
Python
ekzotika, 2020-09-03 17:51:10

How to get values ​​from OrderedDict?

How to get values ​​from OrderedDict?

[OrderedDict([('name', 'Запасные части для специальной техники'), ('code', 'HD')])]


But the object itself is presented to me as a list (I looked in the debugger), that is, you need to get the value using iteration. Tell me, please, how best to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MechanicZelenyy, 2020-09-03
@ekzotika

Just like from a regular dict. And why you put it inside the list, I don't know.

In [1]: from collections import OrderedDict                                     

In [2]: order_dict = OrderedDict([('name', 'Запасные части для специальной техни
   ...: ки'), ('code', 'HD')])                                                  
In [4]: order_dict["name"]                                                      
Out[4]: 'Запасные части для специальной техники'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question