I want to get a list of dictionary from a list of data. I converted the data to a list of strings.The next step was to convert the list of strings to dictionary.But it must be in a order in which each of element in data1 contains data2.Example:
'data1_Element1':'data2_Element1',
'data1_Element1':'data2_Element2',
'data1_Element1':'data2_Element3',
'data1_Element1':'data2_Element4',
..........like a,b+1 pattern.
Make list you well make it in values dictionnarie Will be sorted last elements [data2_element1,data2_ekement2,...]
def sort_list_last(list):
For lis in list:
last= lis[-1]
return sorted(list, key=last)
list = ['data2_element1','data2_ekement2' ,...]
dict = {}
dict['data1_Element1'] = sort_list_list(list)
Print(dict)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.