Table of Contents
UtilData::list2Dict Function
dict list2Dict(list data, string k='stock_id’)
Description
change a list of dict into a dict keyed by k
Paramters
- data list, each item of the list is a dict.
- k string, select the k's value as new for new key in returning dict.
Return
- dict, a new keyed by k, valued by original data.
Detail Information
list2Dict([{’name’:’zhangzhi’, ‘id’:123},{’name’:’cheungzee’, ‘id’:456}], k=’name’) returns: { ‘zhangzhi’:{’name’:’zhangzhi’, ‘id’:123}, ‘cheungzee’:{’name’:’cheungzee’, ‘id’:456} }
Changelog
newly built, 2012-01-21