Python字典怎么在linux系统下运行

发布时间:2021-08-25 15:45:15 作者:chen
来源:亿速云 阅读:123

本篇内容主要讲解“Python字典怎么在linux系统下运行”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Python字典怎么在linux系统下运行”吧!

  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字典怎么在linux系统下运行”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. Linux系统下怎么运行.sh文件
  2. 怎么在python中打印字典

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python linux

上一篇:怎么使用css快速创建3点加载动画

下一篇:怎么用Python字典删除字典元素

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》