Python开发【笔记】:列表转字典

列表转字典

it = [1,2,3,4]
print(dict(zip(it, it)))
# {1: 1, 2: 2, 3: 3, 4: 4}

it = iter(it)
print(dict(zip(it, it)))
# {1: 2, 3: 4}

  

猜你喜欢

转载自www.cnblogs.com/lianzhilei/p/9959929.html
今日推荐