# -*- 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 each of the argument sequences. The returned list is truncated
in length to the length of the shortest argument sequence.
'''
#seq1,seq2:序列 #案例
#每次循环时,从各个序列分别从左到右取出一个元素,合并成一个tuple,然后再组装成list。
list1=[1,2,3]
list2=['xiaodeng','xiaochen','xiaoni']
print zip(list1,list2)#[(1, 'xiaodeng'), (2, 'xiaochen'), (3, 'xiaoni')] #支持2个以上list组装。
ta = [1,2,3]
tb = [9,8,7]
tc = ['a','b','c']
print zip(ta,tb,tc)#[(1, 9, 'a'), (2, 8, 'b'), (3, 7, 'c')] #list长度不对等情况下,按照一般人思维呈现。
list1=[1,2,3,4]
list2=['xiaodeng','xiaochen','xiaoni']
print zip(list1,list2)#[(1, 'xiaodeng'), (2, 'xiaochen'), (3, 'xiaoni')]
list1=[1,2,3]
list2=['xiaodeng','xiaochen']
print zip(list1,list2)#[(1, 'xiaodeng'), (2, 'xiaochen')]

Python之zip的更多相关文章

  1. Python操作Zip文件

    Python操作Zip文件 需要使用到zipfile模块 读取Zip文件 随便一个zip文件,我这里用了bb.zip,就是一个文件夹bb,里面有个文件aa.txt. import zipfile # ...

  2. Python解压缩ZIP格式

    转自:http://blog.csdn.net/linux__kernel/article/details/8271326 很多人在Google上不停的找合适自己的压缩,殊不知Py的压缩很不错.可以试 ...

  3. Python中zip()与zip(*)的用法

    目录 Python中zip()与zip(*)的用法 zip() 知识点来自leetcode最长公共前缀 Python中zip()与zip(*)的用法 可以看成是zip()为压缩,zip(*)是解压 z ...

  4. python中zip函数

    zip函数接受任意多个(包括0个和1个)序列作为参数,返回一个tuple列表.(在海豚实习时自己写了一个要用到zip的函数,那个例子非常代表性) 示例1 for i,j in zip(range(3) ...

  5. Python中zip()函数用法

    定义:zip([iterable, …])zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些tuples组成的l ...

  6. python of zip moudle

    reprinted:http://www.cnblogs.com/beginman/archive/2013/03/14/2959447.html A. code talk is cheap ,sho ...

  7. Python实现 zip解压缩到指定目录

    #!/bin/env python #-*- coding:utf-8 -*- import zipfile,os import platform,sys,os from zipfile import ...

  8. python爆破zip脚本

    最近在提高自己编程能力,拿一些实用的小工具练下.该脚本为python语言,主要涉及模块zipfile,threadings模块. 功能:暴力猜解zip解压密码 #coding: utf-8 impor ...

  9. python写zip破解器

    浏览桌面依然平静,!!!!等等..怎么有个压缩包 打开一看!!!156.txt???waht the fuck? 卧槽还有密码!!!!!! 但是我不知道╮(╯▽╰)╭该怎么办呢! 很简单,python ...

随机推荐

  1. WebSocket重连reconnecting-websocket.js的使用

    原文:https://www.cnblogs.com/kennyliu/p/6477746.html   页面引用 <script src="~/Scripts/reconnectin ...

  2. 在Xcode4.5中禁用ARC(Automatic Referencing Counting) 转

    最近升级了xcode4.5,用上了ios6的SDK.但用着用着发现一个比较烦的问题,以前很多代码提示错误,发现原来因为xcode启用了ARC,当ARC启用后会自动在代码中加入retain.releas ...

  3. sql把一个表的某几列的数据存到另一个表里

    一.如何用slq语句把一个表中的某几个字段的数据插入到另一个新表中,就要用下面这条slq语句:    insert into 表名1(字段1,字段2) select 字段1,字段2 from 表名2 ...

  4. Extjs Ajax 分页

    var storeCpye = new Ext.data.GroupingStore({ proxy : new Ext.data.HttpProxy({ url : 'cxgl_cpye.app?d ...

  5. [翻译] Working with NSURLSession: AFNetworking 2.0

    Working with NSURLSession: AFNetworking 2.0   简单翻译,有很多错误,看官无法理解处请英文原文对照. http://code.tutsplus.com/tu ...

  6. Mac 在启动eclipse时 Failed to load JavaHL Library解决方法

    在Mac 10.9.1系统里, 在Eclipse中安装svn的插件,出现如下提示 方法一: 1.根据提示进入链接 http://subclipse.tigris.org/wiki/JavaHL 2. ...

  7. Android事件分发机制源码分析

    Android事件分发机制源码分析 Android事件分发机制源码分析 Part1事件来源以及传递顺序 Activity分发事件源码 PhoneWindow分发事件源码 小结 Part2ViewGro ...

  8. [GIt] 团队工作效率分析工具gitstats

    copy : http://www.cnblogs.com/ToDoToTry/p/4311637.html 如果你是团队领导,关心团队的开发效率和工作激情:如果你是开源软件开发者,维护者某个repo ...

  9. vld,Bounds Checker,memwatch,mtrace,valgrind,debug_new几种内存泄露检测工具的比较,Valgrind Cheatsheet

    概述 内存泄漏(memory leak)指由于疏忽或错误造成程序未能释放已经不再使用的内存的情况,在大型的.复杂的应用程序中,内存泄漏是常见的问题.当以前分配的一片内存不再需要使用或无法访问时,但是却 ...

  10. mybatis查询时间段sql语句

    转载自:http://blog.csdn.net/zl544434558/article/details/24428307?utm_source=tuicool&utm_medium=refe ...