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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2021-07-24
  • 2021-06-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2021-07-10
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案