Python字典在linux系统下的相关介绍

开发 后端
Python字典在使用的时候我们有不少需要注意的地方。当然我们在的使用的时候只要注意源代码的编写就能更好的使用这个语言。

Python字典的用处非常大,在长时间的使用中我们就会发现,他具有广泛的应用范围,超强的适应能力。下面我们就来看看昨天在网上找了个能在linux跑的字典程序,分享一下。Python字典其实是一个很好使的语言。

  1. #!/usr/bin/python  
  2. f=open(‘wordlist’, ‘w’)  
  3. def xselections(items, n):  
  4. if n==0: yield []  
  5. else:  
  6. for i in xrange(len(items)):  
  7. for ss in xselections(items, n-1):  
  8. yield [items[i]]+ss  
  9. Numbers = 48 – 57  
  10. Capital = 65 – 90  
  11. Lower = 97 – 122  
  12. numb = range(48,58)  
  13. cap = range(65,91)  
  14. low = range(97,123)  
  15. choice = 0 
  16. while int(choice) not in range(1,8):  
  17. choice = raw_input(”’  
  18. 1) Numbers  
  19. 2) Capital Letters  
  20. 3) Lowercase Letters  
  21. 4) Numbers + Capital Letters  
  22. 5) Numbers + Lowercase Letters  
  23. 6) Numbers + Capital Letters + Lowercase Letters  
  24. 7) Capital Letters + Lowercase Letters  
  25. : ”’)  
  26. choice = int(choice)  
  27. poss = []  
  28. if choice == 1:  
  29. poss += numb  
  30. elif choice == 2:  
  31. poss += cap  
  32. elif choice == 3:  
  33. poss += low  
  34. elif choice == 4:  
  35. poss += numb  
  36. poss += cap  
  37. elif choice == 5:  
  38. poss += numb  
  39. poss += low  
  40. elif choice == 6:  
  41. poss += numb  
  42. poss += cap  
  43. poss += low  
  44. elif choice == 7:  
  45. poss += cap  
  46. poss += low  
  47. bigList = []  
  48. for i in poss:  
  49. bigList.append(str(chr(i)))  
  50. MIN = raw_input(“What is the min size of the 
    word? “)  
  51. MIN = int(MIN)  
  52. MAX = raw_input(“What is the max size of 
    the word? “)  
  53. MAX = int(MAX)  
  54. for i in range(MIN,MAX+1):  
  55. for s in xselections(bigList,i): f.write(”.
    join(s) + ‘\n’) 

 

以上就是对Python字典的详细介绍。

【编辑推荐】

  1. Python编程语言总体性能优点评测
  2. Python编程语言具有相当高的适应能力
  3. Python文本乱码发生时的解决方案
  4. Python字符串替换如何才能进行字符的拆分
  5. Python编程版面在应用过程中的功能介绍
责任编辑:张浩 来源: CSDN
相关推荐

2010-02-02 15:13:42

Linux ARM

2009-06-23 18:09:22

2010-03-11 16:50:27

Python应用

2010-03-19 12:49:20

Python编程

2010-07-13 08:19:10

Linux聊天工具

2010-03-10 13:42:44

Python脚本

2010-06-10 17:08:38

2010-03-25 10:13:03

Python代码

2015-08-25 09:35:17

LinuxRAID

2010-03-19 11:04:20

python模块

2009-06-25 08:53:03

Linux操作系统

2011-01-07 09:25:35

LinuxDHCP服务器

2010-03-19 18:36:39

python开发环境

2010-06-29 15:51:22

Linux SNMP协

2011-09-09 18:16:18

WindowsLinux

2010-03-25 16:51:12

Python程序

2010-03-17 17:40:23

Python编程语言

2009-11-06 10:05:18

Linux系统环境GFS

2022-01-26 06:59:46

SFTP操作系统加密算法

2020-09-28 08:12:59

CC++时间
点赞
收藏

51CTO技术栈公众号