Re: iterating over DictRow

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: iterating over DictRow
Дата
Msg-id 7b2272a8-de4d-bc95-1efc-84d69ea7c4c1@aklaver.com
обсуждение исходный текст
Ответ на RE: iterating over DictRow  (David Raymond <David.Raymond@tomtom.com>)
Список psycopg
On 9/24/20 7:53 AM, David Raymond wrote:
> Since DictRow's can be indexed by either the field name or the field index (either record["ID"] or record[0]) then I
thinkwhat it "should" be is a little ambiguous. But you can always either cast it to a dict, or iterate over .keys() if
youwant the field names.
 
> 
> for field in dict(the_dict):
>      ...
> or
> for field in the_dict.keys():
>     ...
> 

Except I think the_dict is actually the_list. I was just about to post a 
reply to my post saying that my use of the_dict was incorrect as I was 
actually iterating over a list.

-- 
Adrian Klaver
adrian.klaver@aklaver.com



В списке psycopg по дате отправления:

Предыдущее
От: David Raymond
Дата:
Сообщение: RE: iterating over DictRow
Следующее
От: Karsten Hilbert
Дата:
Сообщение: Re: iterating over DictRow