我是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. 轉移字符,直到通過2.探索蟒蛇挑戰部分2
- 2. 對於python 2.x中的unicode字符串,等效於string.ascii_letters?
- 3. Prolog實現和/ 2,或/ 2,nand/2,nor/2,xor/2
- 4. 2系列的有效冪:(2^n)+(2 ^(n-1))+(2 ^(n-2))
- 5. java.lang.ArrayIndexOutOfBoundsException:2> = 2
- 6. Angular 2,Ionic 2
- 7. 2層2 mouse_over
- 8. 2 JButtons 2 GUI
- 9. 組2字母2
- 10. 班級角2 2
- 11. IValueProvider MVC 2 RC 2
- 12. 使用Linq讀取2行2行2
- 13. 爲什麼2 /// 2在Javascript中是2?
- 14. 如何解決2 + 2和2 + 2衝突
- 15. 什麼是更好的使用:「2」.toString()=== 2.toString()或「2」== 2?
- 16. iPad 2的Wikitude API 2
- 17. Android ArrayIndexOutOfBoundsException:length = 2;指數= 2
- 18. SecureSocial 2 with play 2 framework
- 19. mapreduce錯誤:java.lang.indexoutofboundsexception:index:2,size:2
- 20. 2挑賽事2個colorbars
- 21. 從2表2的ArrayList
- 22. Sublime Text 2 Licensing - Sublime Text 2
- 23. Zend Framework 2 - Doctrine 2 Model Models
- 24. yui 2 to yui-2-in-3
- 25. Angular 2,Material 2 Radio,Formgroups
- 26. 2個實體的Symfony 2
- 27. Silverlight 2:Silverlight 2中的XamlParseException
- 28. MySQL的2從2個表
- 29. symfony的2 form_row有2場
- 30. COMPARE 2 ITEM IN 2 ARRAY
你應該嘗試執行它。你會看到它只是把最初的兩個字母。 –
是的,我執行它,我知道它的結果如何。我只是不知道這句話是如何實現這一點的。 – Xueyuan