溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Python字典怎么在linux系統(tǒng)下運行

發(fā)布時間:2021-08-25 15:45:15 來源:億速云 閱讀:130 作者:chen 欄目:編程語言

本篇內(nèi)容主要講解“Python字典怎么在linux系統(tǒng)下運行”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“Python字典怎么在linux系統(tǒng)下運行”吧!

  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系統(tǒng)下運行”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI