前提是用list ,有两个list,比如一个是ll=[1,2,3],另一个是ii=["1","2","3"],有什么方法可以使它们的数据一一对应?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
>>> from itertools import izip >>> d1 = {k: v for k, v in izip(ll, ii) >>> d1 {1: '1', 2: '2', 3: '3'}
Sorry I didn’t see the premise using List, I’ll modify it:
>>> map_list = [(k, v) for k, v in izip(ll, ii)] >>> map_list [(1,'1'), (2,'2'), (3,'3')]
Sorry I didn’t see the premise using List, I’ll modify it: