小编Joh*_*gus的帖子

如何将此列表转换为字典

我目前的列表看起来像这样

list =  [['hate', '10'], ['would', '5'], ['hello', '10'], ['pigeon', '1'], ['adore', '10']]
Run Code Online (Sandbox Code Playgroud)

我想把它转换成这样的字典

dict = {'hate': '10', 'would': '5', 'hello': '10', 'pigeon': '1', 'adore': '10'}
Run Code Online (Sandbox Code Playgroud)

因此,基本上list [i][0]将是关键,list [i][1]将是价值观.任何帮助将非常感激 :)

python dictionary list

4
推荐指数
1
解决办法
252
查看次数

标签 统计

dictionary ×1

list ×1

python ×1