Merge branch 'main' into fix_chap1
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
" 对象2.变量5 = 对象2.函数2(对象1.函数1())\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"面向对象编程的出现,使得变量和函数可以根据功能进行整理分类,大大减轻了复杂程序的设计与维护负担。"
|
||||
"面向对象编程的出现,使得变量和函数可以根据功能进行整理分类,通过面向对象的模块化编程,大大减轻了复杂程序的设计与维护负担。"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -132,7 +132,7 @@
|
||||
"类是用来定义对象的 “模板”。\n",
|
||||
"\n",
|
||||
"- 在现实中:类是一组具有相同属性和行为的对象的抽象。例如张三、李四虽然每个人有不同的性格与职业,但他们的基本特征是相似的,都有鼻子有眼能吃饭,因此我们统称他们为“人”类,而每一个人就是一个对象。\n",
|
||||
"- 在 Python 中:类是一组具有相同数据和操作的对象的对象的集合。例如“学生”类可以由学号、姓名、性别、成绩等表示其属性的数据项和对这些数据的录入、修改和显示等操作组成,而每一个特定的学生例如 XiaoHu 就是一个对象。"
|
||||
"- 在 Python 中:类是一组具有相同数据和操作的对象的模板集合。例如“学生”类可以由学号、姓名、性别、成绩等表示其属性的数据项和对这些数据的录入、修改和显示等操作组成,而每一个特定的学生例如 XiaoHu 就是一个对象。"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -198,7 +198,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 1,
|
||||
"id": "whole-translation",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -218,7 +218,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 2,
|
||||
"id": "marked-hello",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -258,7 +258,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 3,
|
||||
"id": "severe-reset",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -281,7 +281,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 4,
|
||||
"id": "manual-montreal",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -314,7 +314,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 42,
|
||||
"execution_count": 5,
|
||||
"id": "black-pakistan",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -352,7 +352,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 43,
|
||||
"execution_count": 6,
|
||||
"id": "south-tongue",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -376,7 +376,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 44,
|
||||
"execution_count": 7,
|
||||
"id": "loose-albuquerque",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -420,7 +420,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": 8,
|
||||
"id": "heavy-jewel",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -437,7 +437,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": 9,
|
||||
"id": "occasional-paint",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -462,7 +462,7 @@
|
||||
"source": [
|
||||
"self 函数用于在类的内部指向对象本身,它是用于连接 类 与 对象 的工具,也是 Python 面向对象编程“多态”特性的一种体现。\n",
|
||||
"\n",
|
||||
"例如在上述代码,我们使用 student 类产生对象 xiaohu,那么 self 就代指 xiaohu;如果我们产生对象 xiaoming,那么 self 就会自动代指 xiaohu。因此 self 参数可以根据不同对象产生不同操作,这体现了面向对象编程的“多态性”。"
|
||||
"例如在上述代码,我们使用 student 类产生对象 xiaohu,那么 self 就代指 xiaohu;如果我们产生对象 xiaoming,那么 self 就会自动代指 xiaoming。因此 self 参数可以根据不同对象产生不同操作,这体现了面向对象编程的“多态性”。"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -470,12 +470,12 @@
|
||||
"id": "daily-impact",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"我们还可以给 student 创建一个用于更改成绩的函数,这样我们后续就不需要通过赋值符号更改对象内的数据:"
|
||||
"我们还可以给 student 创建一个用于更改成绩的方法,这样我们后续就不需要通过赋值符号更改对象内的数据:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 46,
|
||||
"execution_count": 10,
|
||||
"id": "colonial-craps",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -500,7 +500,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 47,
|
||||
"execution_count": 11,
|
||||
"id": "split-burner",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -553,7 +553,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 97,
|
||||
"execution_count": 12,
|
||||
"id": "standard-american",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -592,7 +592,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"execution_count": 13,
|
||||
"id": "level-status",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -644,7 +644,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 58,
|
||||
"execution_count": 14,
|
||||
"id": "reasonable-caribbean",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -654,7 +654,7 @@
|
||||
"int"
|
||||
]
|
||||
},
|
||||
"execution_count": 58,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -669,12 +669,12 @@
|
||||
"id": "above-convention",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"to_byte 将 int 变量转化成 byte 对象 b'\\x00x\\01' 因为整数 1 的二进制编码是 0001。"
|
||||
"to_byte 将 int 对象转化成 byte 对象 b'\\x00x\\01' 因为整数 1 的二进制编码是 0001。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 63,
|
||||
"execution_count": 15,
|
||||
"id": "freelance-briefing",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -718,7 +718,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 16,
|
||||
"id": "c94eed80",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -739,7 +739,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 17,
|
||||
"id": "ac2c2093",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -758,7 +758,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 18,
|
||||
"id": "a05cff81",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -777,7 +777,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 19,
|
||||
"id": "3f916203",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -814,7 +814,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 64,
|
||||
"execution_count": 20,
|
||||
"id": "killing-modern",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -831,12 +831,12 @@
|
||||
"id": "tight-generation",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"通过 \\.\\_\\_name\\_\\_ 方法可以获得函数的名字:"
|
||||
"通过 \\.\\_\\_name\\_\\_ 成员变量可以获得函数的名字:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 74,
|
||||
"execution_count": 21,
|
||||
"id": "extensive-firmware",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -846,7 +846,7 @@
|
||||
"'check_sum'"
|
||||
]
|
||||
},
|
||||
"execution_count": 74,
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
@@ -873,7 +873,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 80,
|
||||
"execution_count": 22,
|
||||
"id": "soviet-determination",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -883,7 +883,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 81,
|
||||
"execution_count": 23,
|
||||
"id": "weighted-ordinance",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -910,7 +910,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 82,
|
||||
"execution_count": 24,
|
||||
"id": "american-continent",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -918,7 +918,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[2, 3, 4, 5]\n"
|
||||
"[1, 3, 4, 5]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -937,7 +937,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 83,
|
||||
"execution_count": 25,
|
||||
"id": "metropolitan-conference",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -945,7 +945,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[1, 2, 3, 4, 5]\n"
|
||||
"[1, 1, 3, 4, 5]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -1020,7 +1020,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 89,
|
||||
"execution_count": 26,
|
||||
"id": "regulated-speed",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -1030,13 +1030,13 @@
|
||||
"'__main__'"
|
||||
]
|
||||
},
|
||||
"execution_count": 89,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"__name__"
|
||||
"__name__\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1072,7 +1072,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 107,
|
||||
"execution_count": 27,
|
||||
"id": "direct-stick",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -1113,7 +1113,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 108,
|
||||
"execution_count": 28,
|
||||
"id": "available-exhibition",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -1157,9 +1157,11 @@
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"interpreter": {
|
||||
"hash": "6e6b1a68f12b475eafe78cfc17c6f5d94c7a04c458bc4083bc2db350380231c7"
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"display_name": "Python 3.9.2 64-bit ('base': conda)",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
|
||||
@@ -430,7 +430,7 @@
|
||||
"\n",
|
||||
"纵观历史,你会看到苹果创始人史蒂夫·乔布斯对 Less is More 的追求,看到无印良品“删繁就简,去其浮华”的核心设计理念,看到山下英子在《断舍离》中对生活做减法的观点,甚至看到苏东坡“一蓑烟雨任平生”的人生态度。你会发现极简主义不只存在于 Python 编程中,它本就是这个世界优雅的一条运行法则。\n",
|
||||
" \n",
|
||||
"本练习让我们导入 this 模块,用心体会一下 Python 的指导原则。\n",
|
||||
"本练习让我们导入 this 模块,用心体会一下 Python 的设计原则。\n",
|
||||
" \n",
|
||||
"</blockquote>"
|
||||
]
|
||||
@@ -503,4 +503,4 @@
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
}
|
||||
|
||||
15
README.md
15
README.md
@@ -30,10 +30,17 @@
|
||||
柏拉图曾经说过:“良好的开端等于成功的一半”。大家选择本教程作为建起万丈高楼的地基,对于我而言便是莫大的荣幸。衷心希望大家在本教程陪伴下迈向未来的同时,也能享受学习过程中带来的乐趣。
|
||||
|
||||
## 如何使用这套教程?
|
||||
1. 本地下载安装 jupyter notebook 打开 ipynb 文件,安装使用方法参考:https://www.jianshu.com/p/91365f343585/
|
||||
2. 在和鲸社区 https://www.heywhale.com 创建项目,上传 .ipynb 文件可在线打开
|
||||
3. 在 Colab 上传 .ipynb 在线打开 (需要科学上网)
|
||||
1. 在 Github 网页版直接打开 ipynb 文件查看
|
||||
2. 本地下载安装 jupyter notebook 运行 ipynb 文件,安装使用方法参考:https://www.jianshu.com/p/91365f343585/
|
||||
3. 在和鲸社区 https://www.heywhale.com 创建项目,上传 .ipynb 文件可在线运行
|
||||
4. 在 Google Colab 上传 .ipynb 在线运行 (需要科学上网)
|
||||
|
||||
## 联系方式
|
||||
知乎 @小雨姑娘
|
||||
Email: cs_xcy@126.com
|
||||
Email: chuanyu.xue@uconn.edu
|
||||
|
||||
## 关注我们
|
||||
<div align=center><img src="https://raw.githubusercontent.com/datawhalechina/pumpkin-book/master/res/qrcode.jpeg" width = "250" height = "270" alt="Datawhale是一个专注AI领域的开源组织,以“for the learner,和学习者一起成长”为愿景,构建对学习者最有价值的开源学习社区。关注我们,一起学习成长。"></div>
|
||||
|
||||
## LICENSE
|
||||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://img.shields.io/badge/license-CC%20BY--NC--SA%204.0-lightgrey" /></a><br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a>进行许可。
|
||||
|
||||
Reference in New Issue
Block a user