[第二章]Python字符串切片示例

来源:互联网 发布:安卓录屏软件哪个好 编辑:程序博客网 时间:2024/04/29 09:28

[第三章] Python使用字符串切片示例

3.16 s = ‘hello’, t = ‘world’, s+= t, 则s、s[-1]、s[2:8]、s[::3]、s[-2::-1]、s[::-1]分别是多少?

>>>s = 'hello'>>>t = 'world'>>>s += t>>>print(s)helloworld>>>s[-1]'d'>>>s[2:8]'llowor'>>>s[::3]'hlod'>>>s[-2::-1]'lrowolleh'>>>s[::-1]'dlrowolleh'
原创粉丝点击