Introduction to the Python dictionary in linux

Source: Internet
Author: User

The Python dictionary is very useful. during a long period of use, we will find that it has a wide range of applications and strong adaptability. Next, let's take a look at a dictionary program that can be run in linux on the internet yesterday and share it with you. The Python dictionary is actually a good language.

 
 
  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’) 

The above is a detailed introduction to the Python dictionary.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.