Skip to content

Commit 8b82602

Browse files
committed
第一章01_base更新为notebook
1 parent 1ff5471 commit 8b82602

249 files changed

Lines changed: 5293 additions & 2422 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

01_base/01.string.py

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# 字符串"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"## 介绍字符串的索引"
15+
]
16+
},
17+
{
18+
"cell_type": "code",
19+
"execution_count": 64,
20+
"metadata": {},
21+
"outputs": [
22+
{
23+
"data": {
24+
"text/plain": [
25+
"'g'"
26+
]
27+
},
28+
"execution_count": 64,
29+
"metadata": {},
30+
"output_type": "execute_result"
31+
}
32+
],
33+
"source": [
34+
"# 字符串的索引\n",
35+
"s = 'good morning'\n",
36+
"# 查看类型 \n",
37+
"print(type(s))\n",
38+
"s[0] # g"
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": 65,
44+
"metadata": {},
45+
"outputs": [
46+
{
47+
"data": {
48+
"text/plain": [
49+
"'n'"
50+
]
51+
},
52+
"execution_count": 65,
53+
"metadata": {},
54+
"output_type": "execute_result"
55+
}
56+
],
57+
"source": [
58+
"s[-2] # n"
59+
]
60+
},
61+
{
62+
"cell_type": "markdown",
63+
"metadata": {},
64+
"source": [
65+
"## 切分操作"
66+
]
67+
},
68+
{
69+
"cell_type": "markdown",
70+
"metadata": {},
71+
"source": [
72+
"\n",
73+
"\n",
74+
"分片用来从序列中提取出想要的子序列,其用法为:\n",
75+
"\n",
76+
"var[lower:upper:step]\n",
77+
"\n",
78+
"其范围包括 lower ,但不包括 upper ,即 [lower, upper),\n",
79+
"step 表示取值间隔大小,如果没有默认为1。\n"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 66,
85+
"metadata": {
86+
"pycharm": {
87+
"name": "#%%\n"
88+
}
89+
},
90+
"outputs": [
91+
{
92+
"data": {
93+
"text/plain": [
94+
"'ing'"
95+
]
96+
},
97+
"execution_count": 66,
98+
"metadata": {},
99+
"output_type": "execute_result"
100+
}
101+
],
102+
"source": [
103+
"s[-3:] # ing"
104+
]
105+
},
106+
{
107+
"cell_type": "code",
108+
"execution_count": 67,
109+
"metadata": {},
110+
"outputs": [
111+
{
112+
"data": {
113+
"text/plain": [
114+
"'good morn'"
115+
]
116+
},
117+
"execution_count": 67,
118+
"metadata": {},
119+
"output_type": "execute_result"
120+
}
121+
],
122+
"source": [
123+
"s[:-3] # good morn"
124+
]
125+
},
126+
{
127+
"cell_type": "code",
128+
"execution_count": 68,
129+
"metadata": {},
130+
"outputs": [
131+
{
132+
"data": {
133+
"text/plain": [
134+
"'good morning'"
135+
]
136+
},
137+
"execution_count": 68,
138+
"metadata": {},
139+
"output_type": "execute_result"
140+
}
141+
],
142+
"source": [
143+
"s[:] # good morning"
144+
]
145+
},
146+
{
147+
"cell_type": "markdown",
148+
"metadata": {},
149+
"source": [
150+
"其他切分操作,练习:step"
151+
]
152+
},
153+
{
154+
"cell_type": "code",
155+
"execution_count": 69,
156+
"metadata": {},
157+
"outputs": [
158+
{
159+
"name": "stdout",
160+
"output_type": "stream",
161+
"text": [
162+
"go onn\n",
163+
"gninrom doog\n",
164+
"good morning\n"
165+
]
166+
}
167+
],
168+
"source": [
169+
"print(s[::2]) # go onn\n",
170+
"print(s[::-1]) # gninrom doog\n",
171+
"print(s[:100])"
172+
]
173+
},
174+
{
175+
"cell_type": "markdown",
176+
"metadata": {},
177+
"source": [
178+
"本节完。"
179+
]
180+
},
181+
{
182+
"cell_type": "code",
183+
"execution_count": null,
184+
"metadata": {},
185+
"outputs": [],
186+
"source": []
187+
}
188+
],
189+
"metadata": {
190+
"kernelspec": {
191+
"display_name": "Python 3",
192+
"language": "python",
193+
"name": "python3"
194+
},
195+
"language_info": {
196+
"codemirror_mode": {
197+
"name": "ipython",
198+
"version": 3
199+
},
200+
"file_extension": ".py",
201+
"mimetype": "text/x-python",
202+
"name": "python",
203+
"nbconvert_exporter": "python",
204+
"pygments_lexer": "ipython3",
205+
"version": "3.8.8"
206+
}
207+
},
208+
"nbformat": 4,
209+
"nbformat_minor": 1
210+
}

01_base/02.list.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)