定义:zip([iterable, …])zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些tuples组成的list(列表).若传入参数的长度不等,则返回list的长度和参数中长度最短的对象相同.利用*号操作符,可以将list unzip(解压),看下面的例子就明白了: >>> a = [1,2,3,4] >>> b = [5,6,7,8] >>> c = [5,
Python dictionary 字典 常用法 d = {} d.has_key(key_in) # if has the key of key_in d.keys() # keys list d.values() # values list d.get(key_in,[defualt]) # it will return 'NoneType' or [default] if with the secon
# -*- coding: utf-8 -*- #python 27 #xiaodeng #Python之zip #http://python.jobbole.com/82590/ #1)zip语法格式: ''' zip(...) zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)] Return a list of tuples, where each tuple contains the i-th element from e