python切片

要求:

helloworld改成helloword

代码:

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

分析:

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

各位大神多多指教
原文地址:https://www.cnblogs.com/dushenda/p/8745615.html