<?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>The Townes &#187; python字典</title>
	<atom:link href="https://thetownes.coolpage.biz/?feed=rss2&#038;tag=python%E5%AD%97%E5%85%B8" rel="self" type="application/rss+xml" />
	<link>https://thetownes.coolpage.biz</link>
	<description>本站已转移至：http://www.thetownes.info</description>
	<lastBuildDate>Thu, 01 Aug 2013 11:49:56 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2</generator>
		<item>
		<title>python的一个字典创建程序</title>
		<link>https://thetownes.coolpage.biz/?p=476</link>
		<comments>https://thetownes.coolpage.biz/?p=476#comments</comments>
		<pubDate>Thu, 01 Aug 2013 03:47:04 +0000</pubDate>
		<dc:creator>Will</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[python字典]]></category>

		<guid isPermaLink="false">http://thetownes.coolpage.biz/?p=476</guid>
		<description><![CDATA[来源：素包子 字典的用处非常大，昨天在网上找了个能在linux跑的字典程序，分享 &#8230; <a href="https://thetownes.coolpage.biz/?p=476">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>来源：素包子</p>
<p>字典的用处非常大，昨天在网上找了个能在linux跑的字典程序，分享一下。<br />
#!/usr/bin/python<br />
f=open(‘wordlist’, ‘w’)<br />
&nbsp;<br />
def xselections(items, n):<br />
&nbsp;&nbsp;&nbsp; if n==0: yield []<br />
&nbsp;&nbsp;&nbsp; else:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i in xrange(len(items)):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ss in xselections(items, n-1):<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; yield [items[i]]+ss<br />
&nbsp;<br />
# Numbers = 48 – 57<br />
# Capital = 65 – 90<br />
# Lower = 97 – 122<br />
numb = range(48,58)<br />
cap = range(65,91)<br />
low = range(97,123)<br />
choice = 0<br />
while int(choice) not in range(1,8):<br />
&nbsp;&nbsp;&nbsp; choice = raw_input(”’<br />
&nbsp;&nbsp;&nbsp; 1) Numbers<br />
&nbsp;&nbsp;&nbsp; 2) Capital Letters<br />
&nbsp;&nbsp;&nbsp; 3) Lowercase Letters<br />
&nbsp;&nbsp;&nbsp; 4) Numbers + Capital Letters<br />
&nbsp;&nbsp;&nbsp; 5) Numbers + Lowercase Letters<br />
&nbsp;&nbsp;&nbsp; 6) Numbers + Capital Letters + Lowercase Letters<br />
&nbsp;&nbsp;&nbsp; 7) Capital Letters + Lowercase Letters<br />
&nbsp;&nbsp;&nbsp; : ”’)<br />
&nbsp;<br />
choice = int(choice)<br />
poss = []<br />
if choice == 1:<br />
&nbsp;&nbsp;&nbsp; poss += numb<br />
elif choice == 2:<br />
&nbsp;&nbsp;&nbsp; poss += cap<br />
elif choice == 3:<br />
&nbsp;&nbsp;&nbsp; poss += low<br />
elif choice == 4:<br />
&nbsp;&nbsp;&nbsp; poss += numb<br />
&nbsp;&nbsp;&nbsp; poss += cap<br />
elif choice == 5:<br />
&nbsp;&nbsp;&nbsp; poss += numb<br />
&nbsp;&nbsp;&nbsp; poss += low<br />
elif choice == 6:<br />
&nbsp;&nbsp;&nbsp; poss += numb<br />
&nbsp;&nbsp;&nbsp; poss += cap<br />
&nbsp;&nbsp;&nbsp; poss += low<br />
elif choice == 7:<br />
&nbsp;&nbsp;&nbsp; poss += cap<br />
&nbsp;&nbsp;&nbsp; poss += low<br />
&nbsp;<br />
bigList = []<br />
for i in poss:<br />
&nbsp;&nbsp;&nbsp; bigList.append(str(chr(i)))<br />
&nbsp;<br />
MIN = raw_input(“What is the min size of the word? “)<br />
MIN = int(MIN)<br />
MAX = raw_input(“What is the max size of the word? “)<br />
MAX = int(MAX)<br />
for i in range(MIN,MAX+1):<br />
&nbsp;&nbsp;&nbsp; for s in xselections(bigList,i): f.write(”.join(s) + ‘ ’)&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://thetownes.coolpage.biz/?feed=rss2&#038;p=476</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
