Python之zip
# -*- 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的更多相关文章
- Python操作Zip文件
Python操作Zip文件 需要使用到zipfile模块 读取Zip文件 随便一个zip文件,我这里用了bb.zip,就是一个文件夹bb,里面有个文件aa.txt. import zipfile # ...
- Python解压缩ZIP格式
转自:http://blog.csdn.net/linux__kernel/article/details/8271326 很多人在Google上不停的找合适自己的压缩,殊不知Py的压缩很不错.可以试 ...
- Python中zip()与zip(*)的用法
目录 Python中zip()与zip(*)的用法 zip() 知识点来自leetcode最长公共前缀 Python中zip()与zip(*)的用法 可以看成是zip()为压缩,zip(*)是解压 z ...
- python中zip函数
zip函数接受任意多个(包括0个和1个)序列作为参数,返回一个tuple列表.(在海豚实习时自己写了一个要用到zip的函数,那个例子非常代表性) 示例1 for i,j in zip(range(3) ...
- Python中zip()函数用法
定义:zip([iterable, …])zip()是Python的一个内建函数,它接受一系列可迭代的对象作为参数,将对象中对应的元素打包成一个个tuple(元组),然后返回由这些tuples组成的l ...
- python of zip moudle
reprinted:http://www.cnblogs.com/beginman/archive/2013/03/14/2959447.html A. code talk is cheap ,sho ...
- Python实现 zip解压缩到指定目录
#!/bin/env python #-*- coding:utf-8 -*- import zipfile,os import platform,sys,os from zipfile import ...
- python爆破zip脚本
最近在提高自己编程能力,拿一些实用的小工具练下.该脚本为python语言,主要涉及模块zipfile,threadings模块. 功能:暴力猜解zip解压密码 #coding: utf-8 impor ...
- python写zip破解器
浏览桌面依然平静,!!!!等等..怎么有个压缩包 打开一看!!!156.txt???waht the fuck? 卧槽还有密码!!!!!! 但是我不知道╮(╯▽╰)╭该怎么办呢! 很简单,python ...
随机推荐
- 报错: LINQ to Entities 不识别方法“Int32 Parse(System.String)
断点调试发现报错的语句为: public ActionResult SomeMethod(string someId) { var temp = SomeService.LoadEntities(a ...
- redis java操作
Redis Java连接操作 连接到Redis服务器 import redis.clients.jedis.Jedis; public class RedisJava { public static ...
- Google In-App Billing 实现(内含Unity 实现经验)
实现内购计费 傻逼目录 Adding the AIDL file Updating Your Manifest Creating a ServiceConnection Making In-app ...
- 7. python 字符串格式化方法(1)
7. python 字符串格式化方法(1) 承接上一章节,我们这一节来说说字符串格式化的另一种方法,就是调用format() >>> template='{0},{1} and {2 ...
- 使用Dictionary泛型集合封装业务逻辑判断 z
C#2.0 提供了Dictionary 泛型类,它提供了从一组键到一组值的映射.字典中的每个添加项都由一个值及其相关联的键组成.通过键来检索值的速度是非常快的,接近于 O(1),这是因为 Dictio ...
- C# 模拟网站登陆
实现此功能首先需要借助一些抓包工具,对相应的网站登陆过程进行分析,此过程根据网站的不同,可能复杂,也可能很简单.常用的抓包工具FF下FireBug和IE下的HttpWatch.这两个工具很强大,以此工 ...
- python垃圾回收杂谈
当创建对象时Python立即向操作系统请求内存.每当对象的引用数减为0,Python垃圾回收器立刻挺身而出,立即将其释放,把内存还给操作系统.在Python中,每个对象都保存了一个称为引用计数的整数值 ...
- mybatis查询时间段sql语句
转载自:http://blog.csdn.net/zl544434558/article/details/24428307?utm_source=tuicool&utm_medium=refe ...
- NLP 依存分析
NLP 依存分析 https://blog.csdn.net/sinat_33741547/article/details/79258045
- 关于DLL文件和EXE文件不在同一目录下的设置【转】
https://www.cnblogs.com/chaosimple/archive/2012/08/13/2636181.html 关于DLL文件和EXE文件不在同一目录下的设置 在开发程序结束后, ...