首页 > python中如何方便的通过两个队列建立字典?

python中如何方便的通过两个队列建立字典?

我现在有两个队列,name=fname.readlins() num=fnum.readlines() 现在想通过这两个队列建立一个字典,如何做比较好?我是通过for循环遍历这两个队列,建立了一个键值对的队列temp,然后用mydict=dict(temp)实现的,但是总感觉这么做非常恶心,请问有没有什么标准化的,或者更好的方法完成呢?
ps:我用的是2.7版


>> a=[1,2,4]
>> b=["new", "world", "right"]
>> dict(zip(a,b))

{1: 'new', 2: 'world', 4: 'right'}

【热门文章】
【热门文章】