【发布时间】:2016-12-05 01:50:39
【问题描述】:
我正在尝试转换类型的列表
list = ['a=1','b=2','c=3','d=4']
到类型的字典
dictionary = {'a':'1', 'b':'2', 'c':'3', 'd':'4'}
我该怎么做?
【问题讨论】:
-
方法有很多。你试过什么?这不是免费的代码编写服务。
-
dict(s.split('=') for s in yourlist).. -
为了将来参考,请花一些时间阅读帮助页面,特别是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。更重要的是,请阅读the Stack Overflow question checklist。您可能还想了解Minimal, Complete, and Verifiable Examples。