简体   繁体   中英

How to have key,key value pair and only keys in python dictionary?

I have a python dictionary,

  P_dic = {'ID': 'STD1'}

and I have output corresponding to this in a list. Lst = ['Len','Lin','lon']

So basically for an ID, there are three values associated to it.

I want to have something like,

 Result = {'ID': 'STD1'}: {'Len','Lin','lon'}}

I am unsure of how to save this inside python dictionary. Please help.

This may help you:

P_dict['lst'] = Lst # from Lst variable

or

P_dict['lst'] = ['Len','Lin','lon']  # direct assignment

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM