小编Tof*_*e H的帖子

在Python中将字符串列表转换为字典

我有一个像这样的字符串列表:

l = ['ABC, Apple, 20021015, 20030102', 'CDE, Graps, 20020506, 20030130']
Run Code Online (Sandbox Code Playgroud)

我想将此列表转换为类似的字典

d = { 'ABC': 'Apple', 'CDE': 'Graps' }
Run Code Online (Sandbox Code Playgroud)

所以键是字符串中的第一个名称,值将是字符串中的第二个名称.

python dictionary python-3.x

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

标签 统计

dictionary ×1

python ×1

python-3.x ×1