How to convert a list into a dictionary in python?

后端 未结 3 2025
说谎
说谎 2021-01-29 14:33

I have a list of objects:

[\'fb_ads_sm\', \'Active\', \'18 hr ago\', \'23\', \'sm_sg13\', \'Pending\', \'12 hr         


        
3条回答
  •  深忆病人
    2021-01-29 15:23

    Try this method: data is your actual list.

    dict_list = {}
    for i in range(0, len(data)-1, 4):
        dict_list[data[i]] = data[i+1]
    

提交回复
热议问题