# -*- 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. golang 字符串与整数, 布尔转换 strconv

    strconv 是golang对于字符串和基本数据类型之间的转换字符串转整数testStr := "1000" testInt, err := strconv.Atoi(testS ...

  2. Testing your Xamarin app on Android device

    I've develop a test application in Xamarin Studio (Android with C#) and wanted to test it on my phon ...

  3. perf 移植

    perf 移植 perf工具用于系统性能的调优,程序优化.源码在kenel/tools/perf目录. 我在imx6平台上进行移植.将自己的移植过程记录如下. 参考链接 http://blog.csd ...

  4. 如何开启解决android studio的模拟器的问题

    来自:http://jingyan.baidu.com/article/03b2f78c0a19e75ea237ae24.html 有的时候因为电脑系统或者是安装的一些问题我们可能需要对症下药的解决模 ...

  5. IE中Ext的comboBox跑到页面左上角

    { xtype:'combo', width:100, //id:'exTypeCom', name:'exType', hiddenName:'exType', displayField:'text ...

  6. python测试开发django-10.django连接mysql

    前言 Django 对各种数据库提供了很好的支持,包括:PostgreSQL.MySQL.SQLite.Oracle.本篇以mysql为例简单介绍django连接mysql进行数据操作 Django连 ...

  7. 使用sun.misc.BASE64Decoder出错解决方案

    Access restriction: The type BASE64Decoder is not accessible due to restriction on required library ...

  8. jQuery元素属性attr设置多个键值或函数 删除属性removeAttr

    $("Element").attr(name) '取得第一个匹配的属性值,比如$("img").attr("src") $("El ...

  9. apache kafka消息服务

    apache kafka中国社区QQ群:162272557 apache kafka参考 http://kafka.apache.org/documentation.html 消息队列分类: 点对点: ...

  10. [MAC OS] 常用工具

    1.Charles mac下的抓包.代理神器 比如我想本地配置 到我的开发机上面.我可以通过Charles 下Tools  -> Map Remote 配置跳转. 2.Postman chrom ...