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 ...
随机推荐
- UML:概要设计,用什么画我的类图?
背景 做过需求之后,很少使用 UML 画概要设计,这几天尝试的用了几个工具,最总还是选择了 VisualStudio. Edraw 详细信息很难编辑,如:签名. Viso 添加成员太麻烦了. Visu ...
- 每天进步一点点——论fork()函数与Linux中的多线程编程
转载请说明出处:http://blog.csdn.net/cywosp/article/details/27316803 一.fork()函数 在操作系统的基本概念中进程是程序的一次运行,且是 ...
- jdbc连接rac的oracle数据库
jdbc连接rac的oracle数据库需要配置所有racIP,如下: DB1 =(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(H ...
- easyui 排序实现
1.对easyui datagrid 返回的数据,进行排序处理,便于搜索到我们的有用的信息. 例如: 2.datagrid 需要设置 sortable : true { field : 'crtTi ...
- [ GIT ] GIT tip : A simple .gitconfig file
reference : http://fle.github.io/git-tip-a-simple-gitconfig-file.html As several friends have asked ...
- mysql访问权限GRANT ALL PRIVILEGES ON,访问权限表
开启远程连接:2, 修改 Mysql-Server 用户配置mysql> USE mysql; -- 切换到 mysql DBDatabase changedmysql> SELECT U ...
- 用Spark查询HBase中的表数据
java代码如下: package db.query; import org.apache.commons.logging.Log; import org.apache.commons.logging ...
- 3D屏保:N皇后
前几天园子里有人发表关于8皇后的算法.只有代码,没有能运行的DEMO多枯燥.于是我这两天抽时间写了个N皇后的屏保程序.程序启动后会从4皇后到14皇后显示其所有排列,每隔0.5秒自动切换一次.按下空格键 ...
- uva 10160 Servicing Stations(DFS+剪枝)
Servicing stations A company offers personal computers for sale in N towns (3 <= N <= 35). The ...
- cesiumjs学习笔记之三——cesium-navigation插件 【转】
http://blog.csdn.net/Prepared/article/details/68940997?locationNum=10&fps=1 插件源码地址:https://githu ...