要求:
helloworld改成helloword
代码:
1 x="helloworld" 2 print(x) 3 y=x[:8]+x[-1] 4 print(y)
分析:
第一位是x[0],最后一位的x[-1],切片是切到第几位之前的。
本文来自博客园,作者:dushenda,转载请注明原文链接:https://www.cnblogs.com/dushenda/p/8745615.html