Home > other >  For help.. Really don't understand how to convert
For help.. Really don't understand how to convert

Time:04-15

Input:
- taskpeos=[' sngao ', 'yueli]
- clas=[' irrelevant ', 'single', 'vehicle scheduling and site maintenance,' one car interaction ', 'ODD related technologies',' vehicle remote control]
- res_list=[[' irrelevant ', '1', '3'], [' vehicle scheduling and site maintenance ', '4', '3'], [' one car interaction ', '5', '2'], [' send single ', '1', '1'], [' vehicle remote control ', '0', '1']]

Output:
- [{' type ':' not 'and' sngao ':' 1 ', 'yueli', '3'}, {' type ':' vehicle scheduling and site maintenance ', 'sngao', '4', 'yueli', '3'}, {' type ':' one car interaction ', 'sngao', '5', 'yueli', '2'}, {' type ':' ODD related technologies', 'sngao' : '0', 'yueli' : '0'}, {' type ':' single ', 'sngao' : '1', 'yueli' : '1'}, {' type ':' vehicle remote control ', 'sngao' : '0', 'yueli' : '1'}]

CodePudding user response:

 
Taskpeos=[' sngao ', 'yueli]
Clas=[' irrelevant ', 'single', 'vehicle scheduling and site maintenance,' one car interaction ', 'ODD related technologies',' vehicle remote control]
Res_list=[[' irrelevant ', '1', '3'], [' vehicle scheduling and site maintenance ', '4', '3'], [' one car interaction ', '5', '2'], [' send single ', '1', '1'], [' vehicle remote control ', '0', '1']]

"'
[{' type ':' not 'and' sngao ':' 1 ', 'yueli', '3'}, {' type ':' vehicle scheduling and site maintenance ', 'sngao', '4', 'yueli', '3'},
{' type ':' one car interaction 'and' sngao ', '5', 'yueli', '2'}, {' type ':' ODD related technologies', 'sngao' : '0', 'yueli' : '0'},
{' type ':' single ', 'sngao' : '1', 'yueli' : '1'}, {' type ':' vehicle remote control ', 'sngao' : '0', 'yueli' : '1'}]
"'

Res=[]
For the item in res_list:
One_res={}
One_res [' type ']=item [0]
One_res [taskpeos [0]]=item [1]
One_res [taskpeos [1]]=item [2]
Res. Append (one_res)

Print (res)

CodePudding user response:

 taskpeos=[' sngao ', 'yueli] 
Clas=[' irrelevant ', 'single', 'vehicle scheduling and site maintenance,' one car interaction ', 'ODD related technologies',' vehicle remote control]
Res_list=[[' irrelevant ', '1', '3'],
[' vehicle scheduling and site maintenance ', '4', '3'],
Car interaction [' people ', '5', '2'),
[' single ', '1', '1'],
[' vehicle remote control ', '0', '1']
]

X=[[k, '0', '0'] in the set for k (clas) - set (I for I, _, _ in res_list)]
Res_list. The extend (x)
Taskpeos=[' type '] + taskpeos
Res=[dict (zip (taskpeos, I)) for I res_list] in
Print (res)

CodePudding user response:

reference 1/f, often should Carla, temperamental predominance, jing yi response:
 
Taskpeos=[' sngao ', 'yueli]
Clas=[' irrelevant ', 'single', 'vehicle scheduling and site maintenance,' one car interaction ', 'ODD related technologies',' vehicle remote control]
Res_list=[[' irrelevant ', '1', '3'], [' vehicle scheduling and site maintenance ', '4', '3'], [' one car interaction ', '5', '2'], [' send single ', '1', '1'], [' vehicle remote control ', '0', '1']]

"'
[{' type ':' not 'and' sngao ':' 1 ', 'yueli', '3'}, {' type ':' vehicle scheduling and site maintenance ', 'sngao', '4', 'yueli', '3'},
{' type ':' one car interaction 'and' sngao ', '5', 'yueli', '2'}, {' type ':' ODD related technologies', 'sngao' : '0', 'yueli' : '0'},
{' type ':' single ', 'sngao' : '1', 'yueli' : '1'}, {' type ':' vehicle remote control ', 'sngao' : '0', 'yueli' : '1'}]
"'

Res=[]
For the item in res_list:
One_res={}
One_res [' type ']=item [0]
One_res [taskpeos [0]]=item [1]
One_res [taskpeos [1]]=item [2]
Res. Append (one_res)

Print (res)
taskpeos this variable is a variable number of parameters, not just two, this is you write is dead, only two of them

CodePudding user response:

refer to the second floor chuifengde response:
 taskpeos=[' sngao ', 'yueli] 
Clas=[' irrelevant ', 'single', 'vehicle scheduling and site maintenance,' one car interaction ', 'ODD related technologies',' vehicle remote control]
Res_list=[[' irrelevant ', '1', '3'],
[' vehicle scheduling and site maintenance ', '4', '3'],
Car interaction [' people ', '5', '2'),
[' single ', '1', '1'],
[' vehicle remote control ', '0', '1']
]

X=[[k, '0', '0'] in the set for k (clas) - set (I for I, _, _ in res_list)]
Res_list. The extend (x)
Taskpeos=[' type '] + taskpeos
Res=[dict (zip (taskpeos, I)) for I res_list] in
Print (res)
for k set (clas) - in the set (I for I, _, _ in res_list), the first inside the underline '-' is what mean
  • Related