python3xiaobaike_2020/chapter2/2-12 python3小白课:索引运算符.md
2025-04-20 23:22:14 +08:00

12 lines
524 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# python3小白课索引运算符
索引运算符之前我们已经遇到过了就是中括号`[]`,通过它可以来表示索引值、索引范围等,这些我们在之前的课程中已经学习过了,所以我们就不再赘述,除了之前我们学习过的内容,索引运算符还能够指定步长,我们来看一下如下的例子:
```python
# coding:utf-8
a = "my name is little bai"
# 取出索引1到索引10不包含10的内容步长为2也是用冒号即可
print(a[1:10:2])
```