blist=[0,1,2,3,4,5,6]
print blist[3:-1]#区间符合左闭由开原则,结果是3,4,5,虽然6的下标是-1,对于任何范围[start:end],需满足start<end(同号下),并否则会返回空的序列,如print blist[3:2],返回空
blist=[0,1,2,3,4,5,6]
print blist[3:-1]#区间符合左闭由开原则,结果是3,4,5,虽然6的下标是-1,对于任何范围[start:end],需满足start<end(同号下),并否则会返回空的序列,如print blist[3:2],返回空
本文标题:切片取数(左闭由开原则)
本文链接:https://www.haomeiwen.com/subject/ahfxgftx.html
网友评论