Python字典的用处非常大,在长时间的使用中我们就会发现,他具有广泛的应用范围,超强的适应能力。下面我们就来看看昨天在网上找了个能在linux跑的字典程序,分享一下。Python字典其实是一个很好使的语言。
网站的建设成都创新互联公司专注网站定制,经验丰富,不做模板,主营网站定制开发.小程序定制开发,H5页面制作!给你焕然一新的设计体验!已为地磅秤等企业提供专业服务。
- #!/usr/bin/python
- f=open(‘wordlist’, ‘w’)
- def xselections(items, n):
- if n==0: yield []
- else:
- for i in xrange(len(items)):
- for ss in xselections(items, n-1):
- yield [items[i]]+ss
- # Numbers = 48 – 57
- # Capital = 65 – 90
- # Lower = 97 – 122
- numb = range(48,58)
- cap = range(65,91)
- low = range(97,123)
- choice = 0
- while int(choice) not in range(1,8):
- choice = raw_input(”’
- 1) Numbers
- 2) Capital Letters
- 3) Lowercase Letters
- 4) Numbers + Capital Letters
- 5) Numbers + Lowercase Letters
- 6) Numbers + Capital Letters + Lowercase Letters
- 7) Capital Letters + Lowercase Letters
- : ”’)
- choice = int(choice)
- poss = []
- if choice == 1:
- poss += numb
- elif choice == 2:
- poss += cap
- elif choice == 3:
- poss += low
- elif choice == 4:
- poss += numb
- poss += cap
- elif choice == 5:
- poss += numb
- poss += low
- elif choice == 6:
- poss += numb
- poss += cap
- poss += low
- elif choice == 7:
- poss += cap
- poss += low
- bigList = []
- for i in poss:
- bigList.append(str(chr(i)))
- MIN = raw_input(“What is the min size of the
word? “)- MIN = int(MIN)
- MAX = raw_input(“What is the max size of
the word? “)- MAX = int(MAX)
- for i in range(MIN,MAX+1):
- for s in xselections(bigList,i): f.write(”.
join(s) + ‘\n’)
以上就是对Python字典的详细介绍。
文章标题:Python字典在linux系统下的相关介绍
浏览路径:http://www.shufengxianlan.com/qtweb/news0/220750.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联