BZ易风

导航

 

str = 'abcdefg'

str[首:尾:步长】 步长为负数的话是倒着取

1 str = 'abcdef'
2 a1 = str[0:4:2]
3 print(a1)   #ac
4 a2 = str[-1:1:-2]
5 print(a2)  #fd

 

posted on 2019-03-17 13:00  BZ易风  阅读(112)  评论(0编辑  收藏  举报