python切片

要求:

helloworld改成helloword

代码:

1 x="helloworld"
2 print(x)
3 y=x[:8]+x[-1]
4 print(y)

分析:

第一位是x[0],最后一位的x[-1],切片是切到第几位之前的。

posted @ 2018-04-08 16:14  dushenda  阅读(108)  评论(0)    收藏  举报