Home > other > On the list in python, dict search problem
On the list in python, dict search problem
Time:09-24
As shown, variable load_dict type data is a list in each data are a dict data dictionary, I want to find a word value=I given the word in the dictionary of data, with no correlation function method can be called directly
CodePudding user response:
To build a large dictionary, need not function, can be directly read a dictionary, Example for small section for your reference
Dict_list=[ {' word ':' king 'and' pingyin ':' wang '}, {' word ':' li ', 'pingyin' : 'li'}, {' word ':' zhao ', 'pingyin' : 'zhao'}, {' word ':' money ', 'pingyin' : 'qian'} ]
Dict_list_new={} For d in dict_list: Dict_list_new [' word '] [d]=d
Print (dict_list_new [' king ']) Print (dict_list_new [' zhao '])