切片对象的demo

 

a = slice(2, 7)
s = 'HelloWorld'
print(a.indices(len(s)))
for i in range(*a.indices(len(s))):
    print(s[i])

 

posted @ 2019-03-21 19:13  anobscureretreat  阅读(211)  评论(0编辑  收藏  举报