looping through multiple lists
map: 最大长度输出;
zip: 最短输出;
third: 有序排列;
a = ['a1', 'a2', 'a3']
b = ['b1', 'b2']
print "Map:"
for x, y in map(None, a, b):
print x, y
# will iterate 2 times,
# the third value of a will not be used
print "Zip:"
for x, y in zip(a, b):
print "{0}, {1}".format(x, y)
# will iterate 6 times,
# it will iterate over each b, for each a
# producing a slightly different outpu
print "List:"
for x, y in [(x,y) for x in a for y in b]:
print x, y
================= RESTART: /Users/vivi/Documents/multlist.py =================
Map:
a1 b1
a2 b2
a3 None
Zip:
a1, b1
a2, b2
List:
a1 b1
a1 b2
a2 b1
a2 b2
a3 b1
a3 b2
looping through multiple lists的更多相关文章
- Displaying SharePoint Lists or Libraries in other sites 显示其他站点的List
Child objects within SharePoint, like a list in a Site, share an inherent connection with that Paren ...
- notes: the architecture of GDB
1. gdb structure at the largest scale,GDB can be said to have two sides to it:1. The "symbol si ...
- MatterTrack Route Of Network Traffic :: Matter
Python 1.1 基础 while语句 字符串边缘填充 列出文件夹中的指定文件类型 All Combinations For A List Of Objects Apply Operations ...
- Sharepoint学习笔记—习题系列--70-576习题解析 -(Q45-Q48)
Question 45 You are designing a branding strategy for a customer with a new SharePoint 2010 server f ...
- Meet Python: little notes 2
From this blog I will turn to Markdown for original writing. Source: http://www.liaoxuefeng.com/ ♥ l ...
- Google上的Cookie Matching
Cookie Matching This guide explains how the Cookie Matching Service enables you to make more effecti ...
- Scala中Zip相关的函数
在Scala中存在好几个Zip相关的函数,比如zip,zipAll,zipped 以及zipWithIndex等等.我们在代码中也经常看到这样的函数,这篇文章主要介绍一下这些函数的区别以及使用. 1. ...
- underscore.js源码解析【数组】
// Array Functions // --------------- // Get the first element of an array. Passing **n** will retur ...
- Underscore.js(1.9.1) 封装库
// Underscore.js 1.9.1// http://underscorejs.org// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and ...
随机推荐
- 判断php的运行模式
我们一般情况下,都是在apache下面运行我们的php程序,当然也有些人是用IIS环境的 我们要是想知道我们目前运行的环境是什么的话,那我们可以用函数php_sapi_name()来测试 代码: &l ...
- poj 2342 hdu 1520【树形dp】
poj 2342 给出每个顶点的happy值,还有若干组两个顶点L,K关系,表示K是L的上司.求当K.L不同时出现时获得的happy值的最大和. 设dp[u][0]表示不选u结点时获得的最大值,dp[ ...
- C# 从零开始写 SharpDx 应用 画三角
原文:C# 从零开始写 SharpDx 应用 画三角 版权声明:博客已迁移到 https://blog.lindexi.com 欢迎访问.如果当前博客图片看不到,请到 https://blog.lin ...
- 2019-8-31-dotnet-通过-WMI-获取系统信息
title author date CreateTime categories dotnet 通过 WMI 获取系统信息 lindexi 2019-08-31 16:55:59 +0800 2019- ...
- Hbase数据模型 时间戳
- selenium webdriver学习(七)------------如何处理alert、confirm、prompt对话框( 转)
selenium webdriver学习(七)------------如何处理alert.confirm.prompt对话框 博客分类: Selenium-webdriver alertpromptc ...
- iptables 规则(Rules)
iptables的每一条规则(rule),都是由两部分组成的,第一部分包含一或多个「过滤条件」其作用是检查包是否符合处理条件(所有条件都必须成立才算数) :第而部分称为「目标」,用於決定如何处置符合条 ...
- Android教程 -05 Android6.0权限的管理
视频为本篇博客知识的讲解,建议采用超清模式观看, 欢迎点击订阅我的优酷 上篇文章我们讲解了通过隐式意图拨打电话,在AndroidManifest.xml文件中添加了权限 <uses-permis ...
- supersockets命令过滤器
关键字: 命令过滤器, 命令, 过滤器, OnCommandExecuting, OnCommandExecuted SuperSocket 中的命令过滤器看起来有些像 ASP.NET MVC 中的 ...
- ThinkPHP商城实战
ThinkPHP3.2.3商城实战教程,需要的联系我,QQ:1844912514 千万级php电商秒杀项目实战 ,需要的联系我,QQ:1844912514