我是Python新手,嘗試播放python挑戰。而在第二級,代碼是: enter image description here 我不明白string.ascii_lowercase[2:] + string.ascii_lowercase[:2]
是什麼意思。另外我在官方文件中找不到它。string.ascii_lowercase [2:] + string.ascii_lowercase [:2]
-2
A
回答
1
也許當步驟seperatly做了最好的解釋:
>>> import string
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
>>> string.ascii_lowercase[:2] # Take the first two items from the string
'ab'
>>> string.ascii_lowercase[2:] # Take everything starting by the third item
'cdefghijklmnopqrstuvwxyz'
>>> string.ascii_lowercase[2:] + string.ascii_lowercase[:2] # concatenate them
'cdefghijklmnopqrstuvwxyzab'
相關問題
- 1. 對於python 2.x中的unicode字符串,等效於string.ascii_letters?
- 2. 2層2 mouse_over
- 3. 2 JButtons 2 GUI
- 4. 班級角2 2
- 5. 組2字母2
- 6. IValueProvider MVC 2 RC 2
- 7. 爲什麼2 /// 2在Javascript中是2?
- 8. 什麼是更好的使用:「2」.toString()=== 2.toString()或「2」== 2?
- 9. 2 asp:updatepanel和2 asp:updateprogress控件
- 10. MVC 2 RC 2問題
- 11. MVC 2 Beta 2 - TempData Bug?
- 12. 答案是:6÷2(1 + 2)=?
- 13. x = 27 * 24 \ 4/2 - 4 + 2
- 14. ViewHolder ArrayIndexOutOfBoundsException:length = 2;指數= 2
- 15. iPad 2的Wikitude API 2
- 16. Angular 2,Webpack 2,AoT編譯
- 17. Mq6 Compcode = 2 CompletionCode = 2 ReasonCode = 2012
- 18. 從2表2的ArrayList
- 19. yui 2 to yui-2-in-3
- 20. SecureSocial 2 with play 2 framework
- 21. 接受(2)不聽(2)
- 22. 2挑賽事2個colorbars
- 23. Silverlight 2:Silverlight 2中的XamlParseException
- 24. Angularfire 2和離子2
- 25. symfony的2 form_row有2場
- 26. VueJS 2 vue-router 2(laravel 5.3)
- 27. 試圖創建用於計算該系列的程序= 1^2 - 2^2 + 3^2
- 28. maxima x^2 + y^2中變量的順序變爲y^2 + x^2
- 29. 初始化參數不同
- 30. 如何在編碼MPEG-2 4:2:2配置文件時將libavcodec設置爲使用4:2:2色度?
你應該嘗試執行它。你會看到它只是把最初的兩個字母。 –
是的,我執行它,我知道它的結果如何。我只是不知道這句話是如何實現這一點的。 – Xueyuan