Python:zip+dict将两个list列表对象转为dict字典对象

将两个list列表对象转为dict字典对象

代码示例


keys = ['one', 'two', 'three']
values = [1, 2, 3]

dct = dict(zip(keys, values))

print(dct)
# {'one': 1, 'two': 2, 'three': 3}

参考文章

  1. Python。将 2 个列表转换为一个字典对象 [重复]

猜你喜欢

转载自blog.csdn.net/mouday/article/details/131261142