python zip函数

来源:互联网 发布:尤克里里调音软件 安卓 编辑:程序博客网 时间:2024/05/16 16:05
通过zip函数将列表转为字典:


s1 = ['a','b','c']

s2 = [1,2,3]

s = zip(s1,s2)

dict1 = dict(s)


Definition : zip(seq1 [, seq2 [...]])

Type : Function of __builtin__ module


zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]


Return a list of tuples, where each tuple contains the i-th element from each of the argument sequences. The returned list is truncated in length to the length of the shortest argument sequence.


0 0