Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dffbb6c

Browse files
feat(day07): Day07 学习笔记
1 parent 7ab8eb7 commit dffbb6c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎day07/index.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Day07 - 字符串和常用数据结构
2+
3+
## 字符串
4+
5+
### 切片
6+
7+
- [廖雪峰 Python 切片](https://www.liaoxuefeng.com/wiki/897692888725344/923029651584288)
8+
9+
```Python
10+
str2 = 'abc123456'
11+
# 从字符串中取出指定位置的字符(下标运算)
12+
print(str2[2]) # c
13+
# 字符串切片(从指定的开始索引到指定的结束索引)
14+
print(str2[2:5]) # c12
15+
print(str2[2:]) # c123456
16+
print(str2[2::2]) # c246
17+
print(str2[::2]) # ac246
18+
print(str2[::-1]) # 654321cba
19+
print(str2[-3:-1]) # 45
20+
```
21+
22+
## 列表
23+
24+
- 排序
25+
- `list = sorted(list)` 返回排序后的结果
26+
- `list.sort()` 直接在列表对象上排序
27+
- [列表生成式](https://www.liaoxuefeng.com/wiki/897692888725344/923029657876192)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /