如何将 列表['1 one', '2 two', '3 three']
转化为 {1:'one',2:'two',3:'three'}

列表相对应的元素 转化为字典
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 溪风沐雪 2022-04-28 15:17关注
lst = ['1 one', '2 two', '3 three'] d = {} for l in lst: d[int(l.split(' ')[0])] = l.split(' ')[1] print(d)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用