<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nine Rivers &#187; unzip</title>
	<atom:link href="http://9rivers.linkka.com/tag/unzip/feed/" rel="self" type="application/rss+xml" />
	<link>http://9rivers.linkka.com</link>
	<description>Molecular modeling in Materials Sciences Web development Programming IT</description>
	<lastBuildDate>Mon, 30 Aug 2010 13:55:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>逆向切分由Python zip函数合并的列表</title>
		<link>http://9rivers.linkka.com/2009/09/11/%e9%80%86%e5%90%91%e5%88%87%e5%88%86%e7%94%b1python-zip%e5%87%bd%e6%95%b0%e5%90%88%e5%b9%b6%e7%9a%84%e5%88%97%e8%a1%a8/</link>
		<comments>http://9rivers.linkka.com/2009/09/11/%e9%80%86%e5%90%91%e5%88%87%e5%88%86%e7%94%b1python-zip%e5%87%bd%e6%95%b0%e5%90%88%e5%b9%b6%e7%9a%84%e5%88%97%e8%a1%a8/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 00:57:58 +0000</pubDate>
		<dc:creator>9rivers</dc:creator>
				<category><![CDATA[编程]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[unzip]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://9rivers.linkka.com/?p=239</guid>
		<description><![CDATA[Unzip a Python list. This is cool! Suppose that you have a list with tuples as the member. 1&#62;&#62;&#62; test = &#91;&#40;'x',1&#41;, &#40;'y',2&#41;, &#40;'z',3&#41;&#93; We can unzip the list by using zip() in conjunction with the * operator. 123456789&#62;&#62;&#62; a, b = zip&#40;*test&#41; &#62;&#62;&#62; a &#40;'x', 'y', 'z'&#41; &#62;&#62;&#62; b &#40;1, 2, 3&#41; 这里涉及到函数星号参数的用法。一个参数加上星号，就表明这一个列表参数，被拆分成len(l)个独立参数传递给函数；如果参数是个字典，就要用两个星号func(**dict)，这时dict的每个键值对都是一个独立的参数，字典有多长，就有多少个独立参数。也因此，上面的unzip代码相当于把一个zip过的列表每一个元素（这里是一个1×2的tuple）分别传递给zip函数，这样zip受到了zip(test[0],test[1],test[2])三个参数，每个参数都是一个tuple，zip后所有元素的第一个值组成了一个新的列表，第二个值组成了第二个列表b，结果就是我们把已经拉上的拉链又打开了。很妙！ 转载请注明来自9rivers。]]></description>
		<wfw:commentRss>http://9rivers.linkka.com/2009/09/11/%e9%80%86%e5%90%91%e5%88%87%e5%88%86%e7%94%b1python-zip%e5%87%bd%e6%95%b0%e5%90%88%e5%b9%b6%e7%9a%84%e5%88%97%e8%a1%a8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
