我是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